Skip to content

Health Check

Health Check #42

Workflow file for this run

name: Health Check
on:
schedule:
- cron: '0 8 * * *' # Daily at 8 AM UTC
workflow_dispatch: # Allow manual trigger
permissions:
issues: write
jobs:
health-check:
runs-on: ubuntu-latest
steps:
- name: Check /health endpoint
run: |
response=$(curl -sf https://currency-rates.moneymatter.app/health)
echo "$response"
echo "$response" | jq -e '.status == "ok"'
- name: Check /currencies returns 30+ currencies
run: |
response=$(curl -sf https://currency-rates.moneymatter.app/currencies)
echo "$response"
count=$(echo "$response" | jq 'length')
echo "Currency count: $count"
[ "$count" -ge 30 ]
- name: Check /latest returns rate data
run: |
response=$(curl -sf https://currency-rates.moneymatter.app/latest)
echo "$response"
echo "$response" | jq -e '.rates | length > 0'
- name: Create issue on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
const title = 'Currency Rates API health check failed';
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'health-check',
});
if (issues.some(issue => issue.title === title)) {
console.log('Issue already exists, skipping creation');
return;
}
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body: `The daily health check failed on ${new Date().toISOString()}.\n\n[View workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`,
labels: ['health-check'],
});