-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (51 loc) · 1.73 KB
/
cd-extract.yml
File metadata and controls
63 lines (51 loc) · 1.73 KB
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
name: CD - Data Extractor
# Only run when merged changes happen in data_extract folder
on:
push:
branches:
- main
paths:
- 'data_extract/**'
- '.github/workflows/cd-extract.yml'
# Manual run
workflow_dispatch:
permissions:
contents: 'read'
id-token: 'write'
# Service configurations in GCP
env:
REGION: us-east1
REPO_NAME: operations-artifacts-dev
IMAGE_NAME: extractor
JOB_NAME: drive-extractor-dev
jobs:
# Call CI-Infra first
infrastructure-check:
uses: ./.github/workflows/ci-infra.yml
secrets: inherit
build-and-deploy:
needs: infrastructure-check
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
# Handshake to GCP
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
service_account: ${{ secrets.DEPLOYER_SA_EMAIL }}
# Handshake to Artifact registry
- name: Configure Docker Auth
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
- name: Build and Push Docker Image
run: |
IMAGE_PATH="${{ env.REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
docker build -f data_extract/Dockerfile -t $IMAGE_PATH .
docker push $IMAGE_PATH
- name: Update Cloud Run Job
run: |
IMAGE_PATH="${{ env.REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
gcloud run jobs update ${{ env.JOB_NAME }} \
--image $IMAGE_PATH \
--region ${{ env.REGION }}