.github/workflows/publish-marketing-site.yml
name: Publish marketing site image
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT }}
REGION: ${{ secrets.GCP_REGION }}
on:
push:
branches:
- 'main'
- 'staging'
- 'test'
- 'vcf'
- 'gcp'
- 'tetrapack'
- 'dev'
- 'demo'
paths:
- 'marketing/**'
- '.github/**'
workflow_dispatch:
inputs:
waitForTest:
description: 'Set to "false" to skip waiting for the test to pass.'
required: true
default: true
jobs:
push_marketing_to_registry:
name: Push Marketing site Docker image to Google Container Registry
runs-on: ubuntu-20.04
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: 'Authenticate to Google Cloud'
uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/168301767246/locations/global/workloadIdentityPools/github-pool/providers/github-provider'
service_account: 'github-actions@landgriffon.iam.gserviceaccount.com'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Authorize Docker push
run: gcloud auth configure-docker europe-west1-docker.pkg.dev
- name: Extract branch name
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "##[set-output name=branch-upper;]$(echo ${GITHUB_REF#refs/heads/} | tr a-z A-Z )"
id: extract_branch
- name: Build Marketing site Docker image
run: |-
docker build \
--build-arg SENDGRID_API_KEY_SUBSCRIPTION=${{ secrets.MARKETING_SENDGRID_API_KEY_SUBSCRIPTION }} \
--build-arg SENDGRID_API_KEY_CONTACT=${{ secrets.MARKETING_SENDGRID_API_KEY_CONTACT }} \
--build-arg NEXT_PUBLIC_GOOGLE_ANALYTICS=${{ secrets.MARKETING_NEXT_PUBLIC_GOOGLE_ANALYTICS }} \
-t europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/marketing/main:${{ github.sha }} \
-t europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/marketing/main:latest ./marketing
docker push europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/marketing/main:${{ github.sha }}
docker push europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/marketing/main:latest
- name: Deploy to Cloud Run
run: |-
gcloud run deploy marketing \
--region ${{ env.REGION }} \
--image europe-west1-docker.pkg.dev/${{ env.PROJECT_ID }}/marketing/main:latest \
--platform "managed" \
--quiet