Skip to content

Deploy Production

Deploy Production #30

name: Deploy Production
permissions:
contents: read
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to deploy'
required: true
default: 'latest'
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
- name: Install Dependencies
run: npm ci
- name: Build Project
run: npm run clean-build
- name: Generate Tag
id: generate_tag
run: |
echo "REV_TAG=prod-$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0.2.1
with:
project_id: ${{ vars.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Deploy to Cloud Run
id: deploy
run: |
gcloud run deploy govuk-knowledge-graph-search \
--source . \
--region "europe-west2" \
--tag ${{ env.REV_TAG }} \
--no-traffic \
--project ${{ vars.GCP_PROJECT_ID }}
- name: Route Traffic to New Revision
run: |
gcloud run services update-traffic govuk-knowledge-graph-search \
--to-tags ${{ env.REV_TAG }}=100 \
--region "europe-west2" \
--project ${{ vars.GCP_PROJECT_ID }}