@@ -186,42 +186,36 @@ jobs:
186186 cache-from : type=gha
187187 cache-to : type=gha,mode=max
188188
189- - name : Setup GCloud
190- uses : google-github-actions/setup-gcloud@v2
191- if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
192- with :
193- service_account_key : ${{ secrets.GKE_SA_KEY }}
194- project_id : ${{ secrets.GKE_PROJECT }}
195-
196189 - name : Auth GCloud
190+ id : gcloud-auth
197191 uses : google-github-actions/auth@v2
198192 if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
199193 with :
200194 credentials_json : ' ${{ secrets.GKE_CJSON }}'
201195
202- - name : Get GKE creds
203- uses : google-github-actions/get-gke-credentials@v2
204- if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
205- with :
206- cluster_name : ${{ secrets.GKE_CLUSTER }}
207- location : ${{ secrets.GKE_ZONE }}
208-
209196 - name : Detect GKE Cluster
197+ id : gcloud-detect-gke
210198 if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
211- id : detect-gke
212199 run : |-
213200 clusters="$(gcloud container clusters list)"
214- echo "Clusters:\n $clusters"
215- is_up="$(echo $clusters | grep cs3219-g16)"
216- echo "Is Cluster Up? $is_up"
201+ is_up="$(echo $clusters | grep ${{ secrets.GKE_CLUSTER }})"
217202 if [[ -z "$is_up" ]]; then
218- echo "output =false" >> $GITHUB_OUTPUT
203+ echo "is_up =false" >> $GITHUB_OUTPUT
219204 else
220- echo "output =true" >> $GITHUB_OUTPUT
205+ echo "is_up =true" >> $GITHUB_OUTPUT
221206 fi
207+
208+ - name : Get GKE creds
209+ id : gcloud-get-gke-creds
210+ uses : google-github-actions/get-gke-credentials@v2
211+ if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' steps.detect-gke.outputs.is_up == 'true' }}
212+ with :
213+ cluster_name : ${{ secrets.GKE_CLUSTER }}
214+ location : ${{ secrets.GKE_ZONE }}
222215
223216 - name : Deploy to GKE
224- if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && steps.detect-gke.output == 'true' }}
217+ id : gcloud-deploy-gke
218+ if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && steps.detect-gke.outputs.is_up == 'true' }}
225219 run : |-
226220 service="${{ matrix.package }}"
227221 deployment="frontend"
0 commit comments