Skip to content

Deploy

Deploy #59

Workflow file for this run

name: Deploy
permissions:
contents: read
id-token: write
on:
push:
branches: [main]
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to ("prod" or "test")'
type: environment
default: test
required: true
env:
BACKEND_IMAGE_REF: us-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT_SLUG }}/firetower-docker/firetower:${{ github.sha }}
STATIC_IMAGE_REF: us-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT_SLUG }}/firetower-docker/nginx:${{ github.sha }}
jobs:
build:
uses: ./.github/workflows/build.yml
deploy:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Authenticate with GCP
uses: 'google-github-actions/auth@v3'
with:
project_id: ${{ secrets.GCP_PROJECT_SLUG }}
workload_identity_provider: projects/${{ secrets.GCP_PROJECT_NUM }}/locations/global/workloadIdentityPools/github/providers/github-prvdr
- name: deploy-test-db-migration
if: ${{ inputs.environment == 'test' }}
uses: "google-github-actions/deploy-cloudrun@v3"
with:
job: firetower-test-db-migration
project_id: ${{ secrets.GCP_PROJECT_SLUG }}
region: us-west1
image: ${{ env.BACKEND_IMAGE_REF }}
wait: true
- name: deploy-test
if: ${{ inputs.environment == 'test' }}
uses: "google-github-actions/deploy-cloudrun@v3"
with:
service: firetower-test
project_id: ${{ secrets.GCP_PROJECT_SLUG }}
region: us-west1
# NOTE: we use flags here because the action does not natively support updating multiple containers.
flags: >
--container nginx --image "${{ env.STATIC_IMAGE_REF }}" --port 80
--container firetower-backend --image "${{ env.BACKEND_IMAGE_REF }}"
- name: deploy-prod-db-migration
if: ${{ (github.ref == 'refs/heads/main' && !inputs.environment ) || inputs.environment == 'prod' }}
uses: "google-github-actions/deploy-cloudrun@v3"
with:
job: firetower-prod-db-migration
project_id: ${{ secrets.GCP_PROJECT_SLUG }}
region: us-west1
image: ${{ env.BACKEND_IMAGE_REF }}
wait: true
- name: deploy-prod
if: ${{ (github.ref == 'refs/heads/main' && !inputs.environment ) || inputs.environment == 'prod' }}
uses: "google-github-actions/deploy-cloudrun@v3"
with:
service: firetower
project_id: ${{ secrets.GCP_PROJECT_SLUG }}
region: us-west1
# NOTE: we use flags here because the action does not natively support updating multiple containers.
flags: >
--container nginx --image "${{ env.STATIC_IMAGE_REF }}" --port 80
--container firetower-backend --image "${{ env.BACKEND_IMAGE_REF }}"