This repository was archived by the owner on Oct 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (43 loc) · 1.6 KB
/
Copy pathdeploy.yml
File metadata and controls
54 lines (43 loc) · 1.6 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
name: Deploy
on:
workflow_run:
workflows: ["Test"]
types: [completed]
branches: [main]
env:
GOOGLE_CLOUD_PROJECT_ID: ${{ vars.GOOGLE_CLOUD_PROJECT_ID }}
GOOGLE_CLOUD_REGION: ${{ vars.GOOGLE_CLOUD_REGION }}
NODE_VERSION: '20'
jobs:
deploy:
runs-on: ubuntu-latest
environment: prod
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
ARTIFACT_REGISTRY: ${{ vars.GOOGLE_CLOUD_REGION }}-docker.pkg.dev/${{ vars.GOOGLE_CLOUD_PROJECT_ID }}/main
steps:
- uses: actions/checkout@v4
- id: auth
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure Docker for Artifact Registry
run: gcloud auth configure-docker ${{ vars.GOOGLE_CLOUD_REGION }}-docker.pkg.dev
- name: Build Docker image
run: |
docker build -t ${{ env.ARTIFACT_REGISTRY }}/api:${{ github.sha }} .
docker tag ${{ env.ARTIFACT_REGISTRY }}/api:${{ github.sha }} ${{ env.ARTIFACT_REGISTRY }}/api:latest
- name: Push Docker image
run: |
docker push ${{ env.ARTIFACT_REGISTRY }}/api:${{ github.sha }}
docker push ${{ env.ARTIFACT_REGISTRY }}/api:latest
- name: Deploy to Cloud Run
run: |
gcloud run deploy api \
--image ${{ env.ARTIFACT_REGISTRY }}/api:${{ github.sha }} \
--region ${{ vars.GOOGLE_CLOUD_REGION }} \
--platform managed \
--allow-unauthenticated