Upgraded packages. #51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: '🚀 Deploy Next.js Docker App (Single Job)' | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build-and-deploy: | |
runs-on: self-hosted | |
name: '🐳 Build & Deploy' | |
steps: | |
- name: '🔍 Checkout Code' | |
uses: actions/checkout@v3 | |
# ======================== | |
# 🔐 Secrets & Config Setup | |
# ======================== | |
- name: '🔒 Verify Secrets Exist' | |
run: | | |
if [ -z "${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}" ]; then | |
echo "❌ Critical error: GOOGLE_SERVICES_JSON_BASE64 secret missing!" | |
exit 1 | |
fi | |
echo "✅ All secrets present" | |
- name: '📁 Create google-services.json' | |
run: | | |
echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 --decode > google-services.json | |
echo "🔄 Validating JSON..." | |
jq empty google-services.json # Requires jq installed | |
env: | |
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }} | |
- name: '⚙️ Create .env File' | |
run: | | |
echo "${{ secrets.ENV_FILE_CONTENT }}" > .env | |
echo "" >> .env # Ensure trailing newline | |
# ======================== | |
# 🐳 Docker Operations | |
# ======================== | |
- name: '🛠 Build Docker Image' | |
run: docker build -t codebuilder-webapp:latest . | |
- name: '🗑 Cleanup Old Containers' | |
run: | | |
docker ps -aq --filter name=codebuilder-webapp | xargs -r docker rm -f | |
- name: '🚀 Launch New Container' | |
run: | | |
docker run -d \ | |
--network host \ | |
-p 3000:3000 \ | |
--env-file .env \ | |
--name codebuilder-webapp \ | |
codebuilder-webapp:latest |