-
Notifications
You must be signed in to change notification settings - Fork 4
60 lines (50 loc) · 1.81 KB
/
deploy-prod.yml
File metadata and controls
60 lines (50 loc) · 1.81 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
name: Deploy to Production
on:
release:
types: [published]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Cloud Auth
uses: google-github-actions/auth@v2
with:
create_credentials_file: true
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_DEPLOY_SERVICE_ACCOUNT }}
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Check Version Format
run: |
VERSION_REGEX="^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+$"
if [[ "${{ github.ref }}" =~ $VERSION_REGEX ]]; then
echo "Version format is correct"
else
echo "Version format is incorrect"
exit 1
fi
- name: Authorize Docker
run: |
gcloud auth configure-docker us-west1-docker.pkg.dev --quiet
- name: Build and Push Image
run: |
IMAGE_NAME="us-west1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/reverse-watch/prod:${{ github.ref_name }}"
docker build --tag $IMAGE_NAME .
docker push $IMAGE_NAME
- name: Deploy to Cloud Run
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_RUNTIME_SERVICE_ACCOUNT: ${{ secrets.GCP_RUNTIME_SERVICE_ACCOUNT }}
GCP_CLOUDSQL_INSTANCE_NAME: ${{ secrets.GCP_CLOUDSQL_INSTANCE_NAME }}
GITHUB_REF_NAME: ${{ github.ref_name }}
run: |
envsubst < deploy/reverse-watch-service.yaml > service.yaml
gcloud run services replace service.yaml