@@ -105,7 +105,7 @@ jobs:
105105 echo "Outputs Generated: $formatted_matrix"
106106 echo "matrix=$formatted_matrix" >> $GITHUB_OUTPUT
107107
108- build-and- push-image :
108+ build-push-deploy -image :
109109 needs : changes
110110 if : ${{ fromJson(needs.changes.outputs.matrix)[0] != null }}
111111 runs-on : ubuntu-latest
@@ -186,14 +186,38 @@ 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+
196+ - name : Get GKE creds
197+ 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 }}
199+ with :
200+ cluster_name : ${{ secrets.GKE_CLUSTER }}
201+ location : ${{ secrets.GKE_ZONE }}
202+ credentials : ${{ secrets.GKE_SA_KEY }}
203+
204+ - name : Deploy to GKE
205+ if : ${{ contains(github.ref, 'main') && github.event.pull_request.title != 'Feedback' && env.IS_GKE_CLUSTER_UP }}
206+ 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+
212+
189213 results :
190214 if : ${{ always() && !github.event.pull_request.draft }}
191215 runs-on : ubuntu-latest
192216 name : Final Results
193- needs : build-and- push-image
217+ needs : build-push-deploy -image
194218 steps :
195219 - run : |
196- result="${{ needs.build-and- push-image.result }}"
220+ result="${{ needs.build-push-deploy -image.result }}"
197221 if [[ $result == "success" || $result == "skipped" ]]; then
198222 exit 0
199223 else
0 commit comments