-
Notifications
You must be signed in to change notification settings - Fork 50
66 lines (57 loc) · 2.03 KB
/
mig_status_check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: doughnut GCP MIG Status Check
on:
schedule:
- cron: '0 */6 * * *'
env:
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
jobs:
Check-Rollout:
name: Check GCP MIG Stability
runs-on: ${{ vars.RUNNER }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/gcloud_auth_n_sdk
with:
credentials_json: ${{ env.GCP_CREDENTIALS }}
- name: Check doughnut MIG Status
run: |
PROJECT_ID=$(gcloud config get-value project)
ZONE=us-east1-b
MIG_NAME=doughnut-app-group
# Check MIG status
max_attempts=3
attempt=1
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt: Checking MIG status..."
status=$(gcloud compute instance-groups managed describe $MIG_NAME \
--project=$PROJECT_ID \
--zone=$ZONE \
--format='value(status.isStable)' 2>&1)
if [ $? -eq 0 ]; then
status_case_insensitive=$(echo "$status" | tr '[:upper:]' '[:lower:]')
if [ "$status_case_insensitive" = "true" ]; then
echo "doughnut MIG is STABLE."
exit 0
else
echo "doughnut MIG is NOT Stable. Current status: $status"
fi
else
echo "Error querying doughnut MIG status: $status"
echo "Retrying..."
fi
sleep 120
attempt=$((attempt+1))
done
echo "doughnut MIG did not stabilize within the expected time"
echo "Final doughnut MIG details:"
gcloud compute instance-groups managed describe $MIG_NAME \
--project=$PROJECT_ID \
--zone=$ZONE
exit 1
- name: Send Notification on Failure
if: failure()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: "doughnut MIG Status Check Failed. Please check the logs for more details."
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}