@@ -2,11 +2,14 @@ name: PD triggered health-check
22on :
33 repository_dispatch :
44 types : [health-check]
5- outputs :
65
76jobs :
8- run-health-check :
7+ get_incident_details :
98 runs-on : ubuntu-latest
9+ outputs :
10+ cluster : ${{ steps.details.outputs.cluster }}
11+ hub : ${{ steps.details.outputs.hub }}
12+ provider : ${{ steps.details.outputs.provider }}
1013 steps :
1114 - name : Get the incident details
1215 id : details
@@ -29,67 +32,54 @@ jobs:
2932 f.write(f"{cluster}\n")
3033 f.write(f"{hub}\n")
3134 f.write(f"{provider}")
32- - uses : actions/checkout@v6
33- with :
34- submodules : true
35- - uses : actions/setup-python@v6
36- with :
37- python-version : ' 3.13'
38- - name : Save pip's install cache on job completion
39- uses : actions/cache@v5
40- with :
41- path : ~/.cache/pip
42- key : ${{ github.run_id }}
4335
44- - name : Install deployer script's Python dependencies
45- run : |
46- pip install --editable .
47- go install github.com/google/go-jsonnet/cmd/jsonnet@v0.20.0
48-
49- - name : Setup deploy for ${{ steps.details.outputs.cluster }} cluster
50- uses : ./.github/actions/setup-deploy
51- with :
52- provider : ${{ steps.details.outputs.provider }}
53- GCP_KMS_DECRYPTOR_KEY : ${{ secrets.GCP_KMS_DECRYPTOR_KEY }}
54-
55- - name : Run health check against ${{ steps.details.outputs.cluster }} ${{ steps.details.outputs.hub }}
56- uses : nick-fields/retry@v3
57- continue-on-error : true
58- id : health_check
59- with :
60- timeout_minutes : 10
61- max_attempts : 3
62- command : |
63- echo "health_check_output<<EOF" | tee --append "$GITHUB_OUTPUT"
64- deployer run-hub-health-check ${{ steps.details.outputs.cluster }} ${{ steps.details.outputs.hub }} | tee --append "$GITHUB_OUTPUT"
65- echo "EOF" | tee --append "$GITHUB_OUTPUT"
36+ health_check :
37+ needs : get_incident_details
38+ uses : ./.github/workflows/reusable-health-check.yaml
39+ with :
40+ cluster : ${{ needs.get_incident_details.outputs.cluster }}
41+ hub : ${{ needs.get_incident_details.outputs.hub }}
42+ provider : ${{ needs.get_incident_details.outputs.provider }}
43+ secrets : inherit
6644
45+ report_status :
46+ needs : [get_incident_details, health_check]
47+ runs-on : ubuntu-latest
48+ steps :
6749 - name : Report Status
6850 if : always()
6951 uses : ravsamhq/notify-slack-action@v2
7052 with :
7153 notify_when : success,failure
72- status : ${{ job.status }} # required
73- notification_title : Health check status for <${{ env.URL }}|${{ steps.details .outputs.cluster }} ${{ steps.details .outputs.hub }}>
74- message_format : ' :point_right: ${{ job.status }}'
54+ status : ${{ needs.health_check.result }}
55+ notification_title : Health check status for <${{ env.URL }}|${{ needs.get_incident_details .outputs.cluster }} ${{ needs.get_incident_details .outputs.hub }}>
56+ message_format : ' :point_right: ${{ needs.health_check.result }}'
7557 mention_groups : ' !channel'
7658 mention_groups_when : failure
7759 footer : <{run_url}|GitHub Run>
7860 env :
7961 SLACK_WEBHOOK_URL : ${{ secrets.SLACK_PD_NOTIFICATIONS_WEBHOOK_URL }}
8062 URL : https://2i2c-org.pagerduty.com/incidents/${{ github.event.client_payload.id }}
8163
64+ - name : Set note content
65+ id : note
66+ run : |
67+ if [[ "${{ needs.health_check.outputs.health_check_output }}" == *"Skipping"* ]]; then
68+ echo "note_content=Health check skipped" >> "$GITHUB_OUTPUT"
69+ else
70+ echo "note_content=Health check status was: ${{ needs.health_check.result }}" >> "$GITHUB_OUTPUT"
71+ fi
8272
8373 - name : Leave a note to the incident
8474 uses : ./.github/actions/pagerduty-note
8575 with :
8676 incident_id : ${{ github.event.client_payload.id }}
8777 token : ${{ secrets.PD_TOKEN }}
88- note_content : ' The health checks status was: ${{ job.status }}'
78+ note_content : ${{ steps.note.outputs.note_content }}
8979
9080 - name : Resolve the incident if successful run
9181 # We don't yet run health checks against binders
92- if : steps .health_check.outcome == 'success' && !contains(steps .health_check.outputs.health_check_output, 'Skipping')
82+ if : needs .health_check.result == 'success' && !contains(needs .health_check.outputs.health_check_output, 'Skipping')
9383 env :
9484 ID : ${{ github.event.client_payload.id }}
9585 PD_TOKEN : ${{ secrets.PD_TOKEN }}
0 commit comments