@@ -186,29 +186,45 @@ 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' && 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+
196208 - name : Get GKE creds
209+ id : gcloud-get-gke-creds
197210 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' }}
199212 with :
200213 cluster_name : ${{ secrets.GKE_CLUSTER }}
201214 location : ${{ secrets.GKE_ZONE }}
202- credentials : ${{ secrets.GKE_SA_KEY }}
203215
204216 - 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' }}
206219 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"
212228
213229 results :
214230 if : ${{ always() && !github.event.pull_request.draft }}
0 commit comments