|
| 1 | +name: Dependabot Failure Watcher |
| 2 | + |
| 3 | +# Dependabot version updates run as GitHub Actions workflow runs named |
| 4 | +# "Dependabot Updates". This scheduled job looks back over the past week for any |
| 5 | +# of those runs that failed and fails itself if it finds one, so a silently-broken |
| 6 | +# ecosystem surfaces as a red scheduled run instead of only a red triangle in the |
| 7 | +# Dependabot tab that nobody checks. |
| 8 | +# |
| 9 | +# Runs entirely within this repo (no external service). A failed scheduled run |
| 10 | +# emails the person who last edited the cron below. Note: GitHub auto-disables |
| 11 | +# scheduled workflows after 60 days of repo inactivity. |
| 12 | + |
| 13 | +on: |
| 14 | + schedule: |
| 15 | + - cron: "17 14 * * 3" # Wednesdays 14:17 UTC |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +permissions: |
| 19 | + actions: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + check-dependabot-runs: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - name: Fail if any Dependabot update failed in the last 8 days |
| 26 | + env: |
| 27 | + GH_TOKEN: ${{ github.token }} |
| 28 | + REPO: ${{ github.repository }} |
| 29 | + run: | |
| 30 | + since=$(date -u -d '8 days ago' +%Y-%m-%dT%H:%M:%SZ) |
| 31 | + failures=$(gh run list \ |
| 32 | + --repo "$REPO" \ |
| 33 | + --workflow "Dependabot Updates" \ |
| 34 | + --limit 100 \ |
| 35 | + --json conclusion,createdAt,displayTitle,url \ |
| 36 | + --jq "[.[] | select((.conclusion == \"failure\" or .conclusion == \"startup_failure\" or .conclusion == \"timed_out\") and .createdAt >= \"$since\")]") |
| 37 | + count=$(echo "$failures" | jq 'length') |
| 38 | + if [ "$count" -gt 0 ]; then |
| 39 | + echo "::error::$count failed Dependabot update run(s) in the last 8 days:" |
| 40 | + echo "$failures" | jq -r '.[] | "- \(.displayTitle) (\(.createdAt))\n \(.url)"' |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + echo "No failed Dependabot update runs in the last 8 days." |
0 commit comments