@@ -186,42 +186,36 @@ jobs:
186
186
cache-from : type=gha
187
187
cache-to : type=gha,mode=max
188
188
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
-
196
189
- name : Auth GCloud
190
+ id : gcloud-auth
197
191
uses : google-github-actions/auth@v2
198
192
if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
199
193
with :
200
194
credentials_json : ' ${{ secrets.GKE_CJSON }}'
201
195
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
-
209
196
- name : Detect GKE Cluster
197
+ id : gcloud-detect-gke
210
198
if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
211
- id : detect-gke
212
199
run : |-
213
200
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 }})"
217
202
if [[ -z "$is_up" ]]; then
218
- echo "output =false" >> $GITHUB_OUTPUT
203
+ echo "is_up =false" >> $GITHUB_OUTPUT
219
204
else
220
- echo "output =true" >> $GITHUB_OUTPUT
205
+ echo "is_up =true" >> $GITHUB_OUTPUT
221
206
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 }}
222
215
223
216
- 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' }}
225
219
run : |-
226
220
service="${{ matrix.package }}"
227
221
deployment="frontend"
0 commit comments