Skip to content

Sync AlphaGameBot Metrics Dashboard #199

Sync AlphaGameBot Metrics Dashboard

Sync AlphaGameBot Metrics Dashboard #199

# This here is my absolutely "what the heck am i doing" way of syncing
# my grafana dashboard to this repo.
# Why?
# Why not? And it's none of your beeswax, isn't it?
name: Sync AlphaGameBot Metrics Dashboard
on:
schedule:
- cron: "0 8 * 11,12,1,2,3 *" # 00:00 PST (08:00 UTC): Nov–Mar
- cron: "0 7 * 4-10 *" # 00:00 PDT (07:00 UTC): Apr–Oct (daylight saving time)
workflow_dispatch: # also allow manual triggering--Only for debugging.
permissions:
contents: write # to push changes back to the repo
jobs:
sync-dashboard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pull dashboard from Grafana
run: |
mkdir -p infra/grafana
curl -s \
-H "Authorization: Bearer ${{ secrets.GRAFANA_API_KEY }}" \
-H "Content-Type: application/json" \
https://grafana.alphagame.dev/api/dashboards/uid/abaff5e0-29c2-4fa5-8337-a89f7abaa907 \
| jq '.dashboard' > infra/grafana/alphagamebot-metrics.json
- name: Commit and push if changed
run: |
git config user.name "Grafana Sync [bot]"
git config user.email "grafana-sync@alphagame.dev"
git add infra/grafana/alphagamebot-metrics.json
VERSION=$(jq -r '.version' infra/grafana/alphagamebot-metrics.json)
COMMIT_FILE=$(mktemp)
printf "metrics: Sync Grafana Metrics Dashboard to version %s [skip ci]\n\nDashboard version: %s" "$VERSION" "$VERSION" > "$COMMIT_FILE"
# `git diff --cached --quiet` returns exit code 1 if there are changes, 0 otherwise.
git diff --cached --quiet || git commit -F "$COMMIT_FILE"
git push