Skip to content

Add GitHub Actions health check workflow #4

Add GitHub Actions health check workflow

Add GitHub Actions health check workflow #4

Workflow file for this run

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: []

Check failure on line 17 in .github/workflows/health_check.yml

View workflow run for this annotation

GitHub Actions / Health Check

Invalid workflow file

The workflow is not valid. .github/workflows/health_check.yml (Line: 17, Col: 19): Matrix vector 'endpoint' does not contain any values
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