-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (51 loc) · 1.93 KB
/
gcp.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
name: Build and Deploy to Cloud Run
on:
push:
branches: [ main, feature/version-auto ]
env:
PROJECT_ID: number-one-fan
REGION: us-central1
SERVICE: nof-landing # cloud run service name
IMAGE_NAME: nof-landing
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Google Auth
id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.SERVICE_ACCOUNT_KEY }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
- name: Set NOF_VERSION in environment
id: env-nof-version
run: |
bash ./scripts/product_version.sh -v patch
- name: Build Docker Image
run: docker build -t ${{ env.IMAGE_NAME }}:latest .
- name: Automatic Tagging of Releases
id: increment-git-tag
run: |
bash ./scripts/git_update.sh -v patch
# the above can be changed to major, minor or patch (e.g 2.1.3 respectively)
- name: Configure Docker Client
run: |-
gcloud auth configure-docker --quiet
- name: Push Docker Image to Google Cloud Container Registry (GCR)
env:
GIT_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
run: |-
docker tag ${{ env.IMAGE_NAME }}:latest gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:latest
docker tag ${{ env.IMAGE_NAME }}:latest gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:$GIT_TAG
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:latest
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:$GIT_TAG
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v0
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
image: gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:latest