Skip to content

build: update dependencies #79

build: update dependencies

build: update dependencies #79

Workflow file for this run

name: cms-cloud-run
on:
push:
branches:
- main
paths:
- '**/cms-cloud-run.yml'
- 'packages/cms/**'
- 'Dockerfile.cms'
env:
CLOUD_RUN_PROJECT_ID: ${{ secrets.CLOUD_RUN_PROJECT_NAME }}
CLOUD_RUN_REGION: europe-north1
REPO_NAME: js-machine-next-cms
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
APP_KEYS: ${{ secrets.APP_KEYS }}
API_TOKEN_SALT: ${{ secrets.API_TOKEN_SALT }}
ADMIN_JWT_SECRET: ${{ secrets.ADMIN_JWT_SECRET }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
INSTANCE_UNIX_SOCKET: ${{ secrets.INSTANCE_UNIX_SOCKET }}
jobs:
build-and-deploy:
name: Setup, Build, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Auth Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Enable the necessary APIs and enable docker auth
run: |-
gcloud services enable artifactregistry.googleapis.com
gcloud services enable run.googleapis.com
gcloud --quiet auth configure-docker $CLOUD_RUN_REGION-docker.pkg.dev
- name: Build and tag image
run: |-
docker build -f Dockerfile.cms . --tag "$CLOUD_RUN_REGION-docker.pkg.dev/$CLOUD_RUN_PROJECT_ID/$REPO_NAME/$GITHUB_SHA" --build-arg DATABASE_NAME=$DATABASE_NAME --build-arg DATABASE_USER=$DATABASE_USER --build-arg DATABASE_PASSWORD=$DATABASE_PASSWORD --build-arg APP_KEYS=$APP_KEYS --build-arg API_TOKEN_SALT=$API_TOKEN_SALT --build-arg ADMIN_JWT_SECRET=$ADMIN_JWT_SECRET --build-arg JWT_SECRET=$JWT_SECRET --build-arg INSTANCE_UNIX_SOCKET=$INSTANCE_UNIX_SOCKET
- name: Push image to registry
run: |-
docker push $CLOUD_RUN_REGION-docker.pkg.dev/$CLOUD_RUN_PROJECT_ID/$REPO_NAME/$GITHUB_SHA
- name: Deploy
run: |-
gcloud components install beta --quiet
gcloud beta run deploy $REPO_NAME --image $CLOUD_RUN_REGION-docker.pkg.dev/$CLOUD_RUN_PROJECT_ID/$REPO_NAME/$GITHUB_SHA \
--project $CLOUD_RUN_PROJECT_ID \
--platform managed \
--region $CLOUD_RUN_REGION \
--allow-unauthenticated \
--max-instances=2 \
--quiet