Skip to content

Merge pull request #28 from onflow/main #22

Merge pull request #28 from onflow/main

Merge pull request #28 from onflow/main #22

name: "Deploy to Production Cloud Run"
on:
push:
branches:
- prod-gcp
env:
# DB VARS
db_username: ${{ secrets.DB_USERNAME }}
db_password: ${{ secrets.DB_PASSWORD }}
db_hostname: ${{ secrets.DB_HOSTNAME }}
db_port: ${{ secrets.DB_PORT }}
db_name: ${{ secrets.DB_NAME }}
backend_api: ${{ secrets.BACKEND_API }}
tx_options: ${{ secrets.TX_OPTIONS }}
hotjar_site_id: ${{ secrets.HOTJAR_STAGE_ID }}
sentry_url: ${{ secrets.SENTRY_STAGE_URL }}
# GCP VARS
BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }}
FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }}
GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }}
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }}
WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google auth
id: auth
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ env.PROJECT_ID }}
- name: Build CAST Backend
run: |-
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev
docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile ./backend
docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }}
- name: Build CAST Frontend
env:
BACKEND: ${{ env.backend_api }}
run: |
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev
docker build -f ./frontend/Dockerfile ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }}
docker push ${{ env.FRONTEND_DOCKER_IMAGE_URL }}
deploy-production-backend:
needs: [build]
environment: production
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google auth
id: auth
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
- name: Deploy Backend to Cloud Run
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ vars.BACKEND_GCP_SERVICE }}
image: ${{ env.BACKEND_DOCKER_IMAGE_URL }}
- name: Deploy Frontend to Cloud Run
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ vars.FRONTEND_GCP_SERVICE }}
image: ${{ env.FRONTEND_DOCKER_IMAGE_URL }}