-
Notifications
You must be signed in to change notification settings - Fork 535
45 lines (39 loc) · 1.35 KB
/
health_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
name: Health Check
on:
push:
pull_request:
workflow_dispatch:
schedule:
# Every 5 minutes
- cron: '*/5 * * * *'
jobs:
health-check:
runs-on: ubuntu-latest
strategy:
matrix:
# Placeholder for endpoints - to be specified later
endpoint: []
fail-fast: false
steps:
- name: Check Version
id: version
shell: bash
run: |
VERSION_JSON=$(curl -s "${{ matrix.endpoint }}/__version__")
echo "Version info for ${{ matrix.endpoint }}:"
echo "$VERSION_JSON"
echo "version_info=$VERSION_JSON" >> "$GITHUB_OUTPUT"
- name: Check Services
shell: bash
run: |
MONITOR_JSON=$(curl -s "${{ matrix.endpoint }}/services/monitor.json")
echo "Services status for ${{ matrix.endpoint }}:"
echo "$MONITOR_JSON"
# Parse JSON and check for down services
echo "Checking for down services..."
echo "$MONITOR_JSON" | jq -r 'to_entries | .[] | select(.value.state == false) | "\(.key) is down: \(.value.status)"'
# If any service is down, check if the JSON contains any false states
if echo "$MONITOR_JSON" | jq -e 'to_entries | .[] | select(.value.state == false)' > /dev/null; then
echo "::error::One or more services are down!"
exit 1
fi