-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (68 loc) · 2.07 KB
/
deploy.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Deploy to Google Cloud Run
on:
push:
branches:
- main
- redeploy-action
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout GitHub Action
uses: actions/checkout@v3
- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=sha
latest
- name: Build and push to GHCR
uses: docker/build-push-action@v4
with:
context: ./src
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
deploy-cloud-run:
runs-on: ubuntu-latest
needs: build-container
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: htan-dcc
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.7.0
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan -target=google_cloud_run_v2_job.default -target=google_cloud_scheduler_job.job
- name: Terraform Apply
run: terraform apply -target=google_cloud_run_v2_job.default -target=google_cloud_scheduler_job.job -auto-approve