1414 SERVICES : db community thread comment vote search popular
1515
1616jobs :
17- setup-build-publish-deploy :
18- name : Setup, Build, Publish, and Deploy
17+ check-cluster :
18+ name : Check if GKE cluster exists
1919 runs-on : ubuntu-latest
20- environment : production
20+ outputs :
21+ exists : ${{ steps.set-exists.outputs.exists }}
2122
2223 permissions :
2324 contents : read
2425 id-token : write
2526
2627 steps :
27- - name : Checkout
28- uses : actions/checkout@v4
29-
3028 - name : Authenticate to Google Cloud
3129 uses : google-github-actions/auth@v2
3230 with :
@@ -37,30 +35,46 @@ jobs:
3735 with :
3836 project_id : ${{ env.PROJECT_ID }}
3937
40- - name : Check if GKE cluster exists
41- id : check-cluster
38+ - id : set-exists
4239 run : |
4340 if gcloud container clusters describe $CLUSTER_NAME --zone $ZONE --project $PROJECT_ID; then
4441 echo "exists=true" >> $GITHUB_OUTPUT
4542 else
46- echo "Cluster does not exist"
4743 echo "exists=false" >> $GITHUB_OUTPUT
4844 fi
4945
46+ build-publish-deploy :
47+ name : Build, Publish, and Deploy
48+ needs : check-cluster
49+ if : needs.check-cluster.outputs.exists == 'true'
50+ runs-on : ubuntu-latest
51+ environment : production
52+
53+ permissions :
54+ contents : read
55+ id-token : write
56+
57+ steps :
58+ - name : Checkout
59+ uses : actions/checkout@v4
60+
61+ - name : Authenticate to Google Cloud
62+ uses : google-github-actions/auth@v2
63+ with :
64+ credentials_json : ${{ secrets.GCP_SA_KEY }}
65+
66+ - name : Set up Google Cloud SDK
67+ uses : google-github-actions/setup-gcloud@v2
68+ with :
69+ project_id : ${{ env.PROJECT_ID }}
70+
5071 - name : Set up GKE credentials
51- if : steps.check-cluster.outputs.exists == 'true'
5272 uses : google-github-actions/get-gke-credentials@v2
5373 with :
5474 project_id : ${{ env.PROJECT_ID }}
5575 cluster_name : ${{ env.CLUSTER_NAME }}
5676 location : ${{ env.ZONE }}
5777
58- - name : Cluster not created. Skip deployment
59- if : steps.check-cluster.outputs.exists == 'false'
60- run : |
61- echo "Cluster doesn't exist — skipping deployment."
62- exit 0
63-
6478 - name : Configure Docker for GCR
6579 run : |
6680 gcloud auth configure-docker --quiet
0 commit comments