Example
GitHub Actions で Site Health Check を定期実行
本番 URL を日次で診断し、スコアが 80 未満になったら Slack へ通知する最小の workflow。
name: Site Health Check (daily)
on:
schedule:
- cron: "0 1 * * *" # JST 10:00
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Run SHC
id: shc
run: |
RES=$(curl -fsSL -X POST "https://infra.yuzlrin.jp/api/v1/site-health-check" \
-H "Authorization: Bearer ${{ secrets.IOH_API_KEY }}" \
-H "content-type: application/json" \
-d '{"url":"https://example.com"}')
SCORE=$(echo "$RES" | jq '.overall.score')
RANK=$(echo "$RES" | jq -r '.overall.rank')
HASH=$(echo "$RES" | jq -r '.hash')
echo "score=$SCORE" >> "$GITHUB_OUTPUT"
echo "rank=$RANK" >> "$GITHUB_OUTPUT"
echo "url=https://infra.yuzlrin.jp/check/$HASH" >> "$GITHUB_OUTPUT"
- name: Notify Slack if score is low
if: steps.shc.outputs.score < 80
run: |
curl -fsSL -X POST "${{ secrets.SLACK_WEBHOOK_URL }}" \
-H "content-type: application/json" \
-d "{\"text\":\"[warn] Site Health Check: rank ${{ steps.shc.outputs.rank }} (score ${{ steps.shc.outputs.score }}) - ${{ steps.shc.outputs.url }}\"}"
Secrets の登録
IOH_API_KEY: Infra Ops Hub のダッシュボードで発行→SLACK_WEBHOOK_URL: Slack の Incoming Webhook URL