-
Notifications
You must be signed in to change notification settings - Fork 143
Add workflow that fails when Dependabot updates error #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Dependabot Failure Watcher | ||
|
|
||
| # Dependabot version updates run as GitHub Actions workflow runs named | ||
| # "Dependabot Updates". This scheduled job looks back over the past week for any | ||
| # of those runs that failed and fails itself if it finds one, so a silently-broken | ||
| # ecosystem surfaces as a red scheduled run instead of only a red triangle in the | ||
| # Dependabot tab that nobody checks. | ||
| # | ||
| # Runs entirely within this repo (no external service). A failed scheduled run | ||
| # emails the person who last edited the cron below. Note: GitHub auto-disables | ||
| # scheduled workflows after 60 days of repo inactivity. | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "17 14 * * 3" # Wednesdays 14:17 UTC | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| actions: read | ||
|
|
||
| jobs: | ||
| check-dependabot-runs: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Fail if any Dependabot update failed in the last 8 days | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| run: | | ||
| since=$(date -u -d '8 days ago' +%Y-%m-%dT%H:%M:%SZ) | ||
| failures=$(gh run list \ | ||
| --repo "$REPO" \ | ||
| --workflow "Dependabot Updates" \ | ||
| --limit 100 \ | ||
| --json conclusion,createdAt,displayTitle,url \ | ||
| --jq "[.[] | select((.conclusion == \"failure\" or .conclusion == \"startup_failure\" or .conclusion == \"timed_out\") and .createdAt >= \"$since\")]") | ||
|
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🌐 Web query:
💡 Result: The GitHub CLI Citations:
🌐 Web query:
💡 Result: The gh run list command supports the --json flag, which allows you to specify a comma-separated list of fields to include in the output [1][2]. The fields updatedAt, createdAt, and startedAt are available for use with this flag [1]. Note that completedAt is not a standard field name for this command; workflow run completion time is typically represented by the updatedAt field once the run has finished [1]. To use these fields, you can execute the command as follows: gh run list --json createdAt,updatedAt,name,status If you need to verify or list all available JSON fields for the command, you can run gh run list --json without any arguments, which will output the full list of supported fields [2]. Citations: Filter on 🤖 Prompt for AI Agents |
||
| count=$(echo "$failures" | jq 'length') | ||
|
Comment on lines
+29
to
+37
|
||
| if [ "$count" -gt 0 ]; then | ||
| echo "::error::$count failed Dependabot update run(s) in the last 8 days:" | ||
| echo "$failures" | jq -r '.[] | "- \(.displayTitle) (\(.createdAt))\n \(.url)"' | ||
| exit 1 | ||
| fi | ||
| echo "No failed Dependabot update runs in the last 8 days." | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '1,120p' .github/workflows/dependabot-failure-watcher.ymlRepository: maxmind/GeoIP2-python
Length of output: 1921
🌐 Web query:
GitHub CLI gh run list disabled workflows --all workflow name filter documentation💡 Result:
To list workflow runs for a disabled workflow using the GitHub CLI (gh), you must use the -w (or --workflow) flag in combination with the -a (or --all) flag [1][2]. By default, the gh run list command does not fetch runs associated with disabled workflows when filtering by a workflow name [1][2]. To include these, you must explicitly pass the -a flag [1][3][2]. Example usage: gh run list -w "Workflow Name" -a Key points regarding this functionality: - Workflow Identification: You can replace "Workflow Name" with the workflow name, workflow ID, or workflow file name [4]. - Filtering Behavior: If you provide a workflow name to the -w flag without the -a flag, the command will not return runs from disabled workflows [1][2]. - Combined Flags: Passing both -w and -a ensures the CLI explicitly fetches runs for that specific workflow even if it is currently disabled [1][2]. For more information on the flags available, you can run gh help run list in your terminal [1][5].
Citations:
run list: do not fail on organization/enterprise ruleset imposed workflows cli/cli#10660-aflag togh run listcli/cli#9162run listdoc with available--jsonfields cli/cli#8934Include disabled workflow runs.
gh run list --workflowskips disabled workflows unless--allis added, so a disabledDependabot Updatesworkflow could make this watcher report a false clean run.Proposed fix
failures=$(gh run list \ --repo "$REPO" \ + --all \ --workflow "Dependabot Updates" \📝 Committable suggestion
🤖 Prompt for AI Agents