-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (56 loc) · 2.05 KB
/
cd-extract.yml
File metadata and controls
71 lines (56 loc) · 2.05 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
64
65
66
67
68
69
70
71
name: Deploy Data Extract Job
# Only run when merged changes happen in data_extract folder
on:
push:
branches:
- main
paths:
- 'data_extract/**'
- '.github/workflows/deploy-pipeline.yml'
workflow_dispatch:
permissions:
contents: 'read'
id-token: 'write'
# Service configurations in GCP
env:
REGION: us-east1
REPO_NAME: operations-artifacts
IMAGE_NAME: extractor
JOB_NAME: drive-extractor
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
# Handshake to GCP
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
service_account: ${{ secrets.DEPLOYER_SA_EMAIL }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
# 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: |
# Full image path using the Git Commit Hash (github.sha)
IMAGE_PATH="${{ env.REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
# Build from root to ensure COPY commands find the files
docker build -f data_extract/Dockerfile -t $IMAGE_PATH .
# Push to Artifact Registry
docker push $IMAGE_PATH
- name: Deploy to 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 deploy ${{ env.JOB_NAME }} \
--image $IMAGE_PATH \
--region ${{ env.REGION }} \
--service-account ${{ secrets.EXTRACTOR_SA_EMAIL }} \
--memory 1Gi \
--cpu 1 \
--task-timeout 15m \
--max-retries 1