-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (57 loc) · 2.1 KB
/
_deployment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Reusable Deployment
on:
workflow_call:
inputs:
environment:
type: string
required: true
description: Name of the target environment.
ref:
type: string
required: true
description: The tag or SHA to checkout.
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Google Auth
id: auth
uses: '
with:
token_format: 'access_token'
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'
- name: Log ingo Google Artifact Registry
id: docker-auth
uses: docker/login-action@v3
with:
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
registry: '${{ vars.REGION }}-docker.pkg.dev'
- name: Build, tag and push container
id: build-image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ vars.REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.ARTIFACT_REPO }}/${{ vars.SERVICE_NAME }}:latest
- name: Create Service declaration
run: |-
export CONTAINER_IMAGE="${{ vars.REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT_ID }}/${{ vars.ARTIFACT_REPO }}/${{ vars.SERVICE_NAME }}:latest"
export SERVICE_NAME="${{ vars.SERVICE_NAME }}"
export PROJECT_ID="${{ vars.GCP_PROJECT_ID }}"
export REVISION_TAG="${{ inputs.ref }}"
export CLOUD_RUN_SA="${{ vars.CLOUD_RUN_SA }}"
export ENVIRONMENT="${{ inputs.environment }}"
envsubst < ./service-yaml/container.yaml > container-${{ inputs.environment }}.yaml
cat container-${{ inputs.environment }}.yaml
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ vars.SERVICE_NAME }}
region: ${{ vars.REGION }}
metadata: container-${{ inputs.environment }}.yaml