@@ -186,29 +186,45 @@ 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' && env.IS_GKE_CLUSTER_UP }}
192
- with :
193
- service_account_key : ${{ secrets.GKE_SA_KEY }}
194
- project_id : ${{ secrets.GKE_PROJECT }}
195
-
189
+ - name : Auth GCloud
190
+ id : gcloud-auth
191
+ uses : google-github-actions/auth@v2
192
+ if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
193
+ with :
194
+ credentials_json : ' ${{ secrets.GKE_CJSON }}'
195
+
196
+ - name : Detect GKE Cluster
197
+ id : gcloud-detect-gke
198
+ if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' }}
199
+ run : |-
200
+ clusters="$(gcloud container clusters list)"
201
+ is_up="$(echo $clusters | grep ${{ secrets.GKE_CLUSTER }})"
202
+ if [[ -z "$is_up" ]]; then
203
+ echo "is_up=false" >> $GITHUB_OUTPUT
204
+ else
205
+ echo "is_up=true" >> $GITHUB_OUTPUT
206
+ fi
207
+
196
208
- name : Get GKE creds
209
+ id : gcloud-get-gke-creds
197
210
uses : google-github-actions/get-gke-credentials@v2
198
- if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && env.IS_GKE_CLUSTER_UP }}
211
+ if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && steps.gcloud-detect-gke.outputs.is_up == 'true' }}
199
212
with :
200
213
cluster_name : ${{ secrets.GKE_CLUSTER }}
201
214
location : ${{ secrets.GKE_ZONE }}
202
- credentials : ${{ secrets.GKE_SA_KEY }}
203
215
204
216
- name : Deploy to GKE
205
- if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && env.IS_GKE_CLUSTER_UP }}
217
+ id : gcloud-deploy-gke
218
+ if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && steps.gcloud-detect-gke.outputs.is_up == 'true' }}
206
219
run : |-
207
- deployments=("collab-service" "matching-service" "question-service" "user-service" "frontend")
208
- for dplymnt in "${deployments[@]}"; do
209
- kubectl -n peerprep rollout restart deployment "$dplymnt"
210
- done
211
-
220
+ service="${{ matrix.package }}"
221
+ deployment="frontend"
222
+ if [[ "$service" == "collaboration" ]]; then
223
+ deployment="collab-service"
224
+ elif [[ "$service" != "frontend" ]]; then
225
+ deployment="$service-service"
226
+ fi
227
+ kubectl -n peerprep rollout restart deployment "$deployment"
212
228
213
229
results :
214
230
if : ${{ always() && !github.event.pull_request.draft }}
0 commit comments