Skip to content

Trying to fix again... #15

Trying to fix again...

Trying to fix again... #15

Workflow file for this run

name: Deploy Next.js Docker App
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: self-hosted
steps:
- name: Check out repository
uses: actions/checkout@v3
# Decode the base64-encoded JSON secret into a file.
- name: Create google-services.json
run: |
echo "${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}" | base64 --decode > google-services.json
# Create the .env file from a secret (if needed)
- name: Create .env file
run: |
printf "%s" "${{ secrets.ENV_FILE_CONTENT }}" > .env
# Debug: Check file size of google-services.json
- name: Check google-services.json file size
run: wc -c google-services.json
# Debug: Validate JSON syntax (this will fail if the JSON is empty or invalid)
- name: Validate google-services.json
run: node -e "JSON.parse(require('fs').readFileSync('google-services.json','utf8'))"
- name: Build Docker image
run: docker build -t codebuilder-webapp:latest .
- name: Stop and remove old container (if running)
run: |
OLD_CONTAINER_ID=$(docker ps -q --filter ancestor=codebuilder-webapp:latest)
if [ -n "$OLD_CONTAINER_ID" ]; then
echo "Stopping and removing container $OLD_CONTAINER_ID..."
docker stop $OLD_CONTAINER_ID
docker rm $OLD_CONTAINER_ID
else
echo "No old container found."
fi
- name: Start new container
run: docker run -d --network host -p 3000:3000 --name codebuilder-webapp codebuilder-webapp:latest