npm up #100
This file contains 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: Build and Deploy to Cloud Run | |
on: | |
push: | |
branches: | |
- main | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT }} | |
SERVICE: ropescore-api | |
REGION: europe-west1 | |
jobs: | |
setup-build-publish-deploy: | |
name: Setup, Build, Publish, and Deploy | |
runs-on: ubuntu-latest | |
environment: | |
name: production | |
url: ${{ steps.deploy.outputs.url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker BuildX as docker build | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
# Setup gcloud CLI | |
- uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
- uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT }} | |
# Configure Docker to use the gcloud command-line tool as a credential | |
# helper for authentication | |
- name: Login to Google Artifact Registry | |
run: gcloud auth configure-docker europe-west1-docker.pkg.dev | |
# Build and Push the Docker image | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: | | |
europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/eu-artifacts/${{ env.SERVICE }}:latest | |
europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/eu-artifacts/${{ env.SERVICE }}:${{ github.sha }} | |
context: . | |
# platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
platforms: linux/amd64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Deploy to Cloud Run | |
id: deploy | |
uses: google-github-actions/deploy-cloudrun@v2 | |
with: | |
service: ${{ env.SERVICE }} | |
image: europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/eu-artifacts/${{ env.SERVICE }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
env_vars: SENTRY_DSN=${{ secrets.SENTRY_DSN }},GCP_PROJECT=${{ secrets.GCP_PROJECT }},FIREBASE_DATABASE_URL=${{ secrets.FIREBASE_DATABASE_URL }},SECRET_NAME=${{ secrets.SECRET_NAME }} | |
flags: --max-instances=3 --concurrency=160 --service-account=${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }} --remove-env-vars=JWT_ALG,JWT_PRIVKEY_PATH,JWT_PUBKEY_PATH --clear-secrets | |
- name: Show Output | |
run: echo ${{ steps.deploy.outputs.url }} |