Files
blackroad-os-api-gateway/.github/workflows/health-check.yml
Alexa Louise 5e89ea83b3 Add GitHub Actions automations
- Security scanning (CodeQL, dependency review, secrets)
- Railway auto-deploy on push to main
- Release automation with Docker image publishing
- Health check monitoring with issue creation
- PR labeler based on files and size
- Dependabot configuration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 10:24:21 -06:00

50 lines
1.7 KiB
YAML

name: Health Check
on:
schedule:
- cron: '*/15 * * * *'
workflow_dispatch:
jobs:
health-check:
name: Check Service Health
runs-on: ubuntu-latest
steps:
- name: Check api-gateway.blackroad.io
id: health
run: |
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://api-gateway.blackroad.io/health --connect-timeout 10 || echo "000")
echo "status=$HTTP_CODE" >> $GITHUB_OUTPUT
if [ "$HTTP_CODE" = "200" ]; then
echo "Service is healthy"
else
echo "Service returned HTTP $HTTP_CODE"
fi
- name: Create issue on failure
if: steps.health.outputs.status != '200'
uses: actions/github-script@v7
with:
script: |
const title = 'Service Health Alert: api-gateway.blackroad.io returned ' + '${{ steps.health.outputs.status }}';
const body = '## Health Check Failed\n\n- **Service**: api-gateway.blackroad.io\n- **Status Code**: ${{ steps.health.outputs.status }}\n- **Time**: ' + new Date().toISOString();
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'health-alert'
});
if (!issues.data.find(i => i.title.includes('Health Alert'))) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['health-alert', 'urgent']
});
}
continue-on-error: true