Skip to content

Deploy to production by @jgarber623 #54

Deploy to production by @jgarber623

Deploy to production by @jgarber623 #54

Workflow file for this run

name: Deploy
run-name: Deploy to production by @${{ github.actor }}
on:
push:
branches: [production]
workflow_dispatch:
branches: [production]
inputs:
merge-main:
description: Merge main branch
required: false
type: boolean
concurrency: production
jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml
build:
name: Build
permissions:
contents: read
id-token: write
packages: write
needs: ci
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Merge main branch and push changes
if: ${{ github.event.inputs.merge-main == 'true' }}
run: |
git merge origin/main
git push
- uses: docker/setup-buildx-action@v3
- uses: google-github-actions/auth@v2
id: gcloud-auth
with:
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
token_format: access_token
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Authenticate to Google Container Registry
uses: docker/login-action@v3
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.gcloud-auth.outputs.access_token }}
- name: Authenticate to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate short SHA
id: vars
run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
- name: Build and push container images
uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
push: true
tags: |
gcr.io/${{ env.GCP_PROJECT }}/${{ github.repository }}:${{ steps.vars.outputs.short_sha }}
gcr.io/${{ env.GCP_PROJECT }}/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.short_sha }}
ghcr.io/${{ github.repository }}:latest
deploy:
name: Deploy
permissions:
contents: read
id-token: write
needs: build
runs-on: ubuntu-latest
environment:
name: production
url: https://indieweb-endpoints.cc
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- uses: google-github-actions/deploy-cloudrun@v2
with:
image: gcr.io/${{ env.GCP_PROJECT }}/${{ github.repository }}
service: indieweb-endpoints-cc-web