Skip to content
Merged
76 changes: 76 additions & 0 deletions .github/workflows/deploy-cloudrun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: 'Reusable gcp cloudrun deploy workflow'

on:
workflow_call:
inputs:
job-name:
required: false
type: string
service-name:
required: false
type: string
Comment thread
coderabbitai[bot] marked this conversation as resolved.
registry:
required: true
type: string
artifact-repository:
required: true
type: string
artifact-tag:
required: true
type: string
region:
required: true
type: string
flags:
type: string
container:
type: string
workload-identity-provider:
required: true
type: string
workload-identity-service-account-mail:
required: true
type: string
Comment thread
coderabbitai[bot] marked this conversation as resolved.
jobs:
deploy_cloudrun:
name: Deployment job
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate inputs
run: |
if [[ -z "${{ inputs.job-name }}" && -z "${{ inputs.service-name }}" ]]; then
echo "Error: at least one of 'job-name' or 'service-name' must be provided"
Comment thread
marek-saji marked this conversation as resolved.
Outdated
Comment thread
marek-saji marked this conversation as resolved.
Outdated
exit 1
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.
- uses: 'google-github-actions/auth@v3'
with:
service_account: ${{ inputs.workload-identity-service-account-mail }}
workload_identity_provider: ${{ inputs.workload-identity-provider }}
- name: 'Prepare deployment flags field'
id: flags
run: |
FLAGS="${{ inputs.flags }}"
if [ -n "${{ inputs.container }}" ]; then
FLAGS="$FLAGS --container ${{ inputs.container }}"
fi
echo "flags=$FLAGS" >> "$GITHUB_OUTPUT"
- name: 'deploy cloudrun job'
if: inputs.job-name != ''
uses: 'google-github-actions/deploy-cloudrun@v3'
with:
image: ${{ inputs.registry }}/${{ inputs.artifact-repository }}:${{ inputs.artifact-tag }}
region: ${{ inputs.region }}
job: ${{ inputs.job-name }}
flags: ${{ steps.flags.outputs.flags }}
- name: 'deploy cloudrun service'
if: inputs.service-name != ''
uses: 'google-github-actions/deploy-cloudrun@v3'
with:
image: ${{ inputs.registry }}/${{ inputs.artifact-repository }}:${{ inputs.artifact-tag }}
region: ${{ inputs.region }}
service: ${{ inputs.service-name }}
flags: ${{ steps.flags.outputs.flags }}