Skip to content

Google services json formatting & newline issue fix. #11

Google services json formatting & newline issue fix.

Google services json formatting & newline issue fix. #11

Workflow file for this run

name: Deploy Next.js Docker App
on:
push:
branches:
- main
jobs:
build-and-deploy:
# Run on your self-hosted runner so it has Docker
runs-on: self-hosted
# Alternatively: runs-on: [self-hosted, linux]
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Create google-services.json
run: |
# Use printf to preserve the formatting and newlines
printf "%s" "${{ secrets.GOOGLE_SERVICES_JSON }}" > google-services.json
- name: Create .env file
run: |
# Similarly, create the .env file with proper formatting
printf "%s" "${{ secrets.ENV_FILE_CONTENT }}" > .env
- name: Build Docker image
run: |
docker build -t codebuilder-webapp:latest .
- name: Stop and remove old container (if running)
run: |
# Find any running container based on the image
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