Skip to content

feat: Dependabot with auto-merge on CI success#3

Merged
Jamie-BitFlight merged 4 commits intomainfrom
copilot/setup-dependabot-auto-merge
Feb 22, 2026
Merged

feat: Dependabot with auto-merge on CI success#3
Jamie-BitFlight merged 4 commits intomainfrom
copilot/setup-dependabot-auto-merge

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

  • Create .github/dependabot.yml for pip and github-actions ecosystems, weekly schedule
  • Create .github/workflows/dependabot-auto-merge.yml with auto-approve and squash auto-merge
  • Fix error[bot-conditions] (HIGH): use github.event.pull_request.user.login + fork guard
  • Fix help[dependabot-cooldown]: default-days set to 7 (zizmor minimum); simplified cooldown to single default-days: 7
  • Add open-pull-requests-limit: 5 to both ecosystems
  • Fix permissions structure: permissions: {} at workflow level, specific at job level
  • Add branches: ["**"] trigger filter (consistent with other workflows)
  • Add fetch-metadata step + skip approve/auto-merge for semver-major updates
Original prompt

can you set up automatic dependabot with merge on success?
include github action updates too


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Jamie-BitFlight <25075504+Jamie-BitFlight@users.noreply.github.com>
Copilot AI changed the title [WIP] Set up automatic dependabot with merge on success feat: Dependabot with auto-merge on CI success Feb 22, 2026
@Jamie-BitFlight Jamie-BitFlight marked this pull request as ready for review February 22, 2026 02:10
Copilot AI review requested due to automatic review settings February 22, 2026 02:10
@Jamie-BitFlight
Copy link
Contributor

please check the ci pipeline errors @copilot

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds automated dependency management via Dependabot with automatic merging once CI passes. It introduces weekly dependency updates for Python packages and GitHub Actions, and implements a workflow that auto-approves and enables auto-merge for Dependabot PRs.

Changes:

  • Adds Dependabot configuration for weekly updates of pip dependencies and GitHub Actions
  • Implements auto-merge workflow that approves Dependabot PRs and enables auto-merge when CI passes
  • Configures appropriate labels for dependency PRs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
.github/dependabot.yml Configures Dependabot for weekly pip and github-actions updates with labeled PRs
.github/workflows/dependabot-auto-merge.yml Workflow to auto-approve and enable auto-merge for Dependabot PRs after CI success

@@ -0,0 +1,26 @@
name: Dependabot Auto-Merge

on: pull_request
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow trigger is missing branch filters. All other workflows in this repository use explicit branch filters (e.g., branches: ["main"] for push, branches: ["**"] for pull_request). This trigger will run on all pull requests to any branch, which may not be the intended behavior. Consider adding branch filters consistent with other workflows to limit when this workflow runs.

Suggested change
on: pull_request
on:
pull_request:
branches: ["**"]

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +13
permissions:
contents: write
pull-requests: write

jobs:
auto-merge:
name: Auto-merge Dependabot PRs
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow-level permissions declaration is inconsistent with other workflows in this repository. All other workflows (ci.yml, zizmor.yml) use permissions: {} at the workflow level and declare specific permissions at the job level. This creates a potential security risk by granting broad permissions to all jobs. Consider following the established pattern: set permissions: {} at the workflow level and declare permissions: with contents: write and pull-requests: write at the job level instead.

Suggested change
permissions:
contents: write
pull-requests: write
jobs:
auto-merge:
name: Auto-merge Dependabot PRs
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
permissions: {}
jobs:
auto-merge:
name: Auto-merge Dependabot PRs
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
permissions:
contents: write
pull-requests: write

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +26
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approval step may fail with a "cannot review your own pull request" error. GitHub Actions' GITHUB_TOKEN is tied to the github-actions[bot] account, but Dependabot PRs are authored by dependabot[bot]. While these are different bot accounts, the approval may still be rejected if GitHub treats them as the same entity or if branch protection rules require human approval. Consider testing this behavior or using a GitHub App token with proper permissions, or document that branch protection must allow bot approvals.

Suggested change
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}
- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +26
- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auto-merge step lacks error handling and doesn't verify that approval succeeded first. If the previous approval step fails but continues, this step will attempt to enable auto-merge on an unapproved PR, which will fail. The workflow should either fail fast on approval errors or check if approval succeeded before attempting auto-merge. Consider adding a conditional check or proper error handling between these steps.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +26
jobs:
auto-merge:
name: Auto-merge Dependabot PRs
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'

steps:
- name: Approve PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Enable auto-merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is missing security filtering for Dependabot PR types. Currently, it will auto-approve and auto-merge all Dependabot PRs regardless of whether they are patch, minor, or major version updates. Major version updates can introduce breaking changes. Consider adding logic to filter by update type (e.g., only auto-merge patch and minor updates) or by dependency criticality. You can access this information via github.event.pull_request.labels or by parsing the PR title/body.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +17
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
- "python"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
- "github-actions"
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dependabot configuration should include additional security settings. The configuration is missing important fields like open-pull-requests-limit (defaults to 5, which may overwhelm CI), rebase-strategy (to handle conflicts), and versioning-strategy (important for GitHub Actions). Consider adding these for better control. For example, limiting open PRs to 3, and for the github-actions ecosystem, consider adding versioning-strategy: "increase" to ensure SHA-pinned actions are updated correctly.

Copilot uses AI. Check for mistakes.
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pip ecosystem configuration should include a groups specification. Looking at pyproject.toml, the project uses dependency groups (dev group with tools like pytest, mypy, ruff). Without the groups field, Dependabot will only update runtime dependencies, not dev dependencies. Add groups: ["dev"] to ensure dev dependencies are also kept up to date.

Suggested change
interval: "weekly"
interval: "weekly"
groups:
- "dev"

Copilot uses AI. Check for mistakes.
…orkflow

Co-authored-by: Jamie-BitFlight <25075504+Jamie-BitFlight@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 22, 2026

please check the ci pipeline errors @copilot

Fixed in e59bd67. There were three zizmor findings causing the CI failure:

  1. error[bot-conditions] (HIGH)github.actor == 'dependabot[bot]' is spoofable via workflow_call. Replaced with the event-payload check recommended by zizmor docs: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == github.event.pull_request.head.repo.full_name

  2. warning[dependabot-cooldown] (MEDIUM) × 2 — both ecosystems in dependabot.yml were missing a cooldown config. Added sensible defaults (patch: 3 days, minor: 5 days, major: 7 days) for both pip and github-actions.

@Jamie-BitFlight
Copy link
Contributor

please do another pass over the failing ci pipelines @copilot

Co-authored-by: Jamie-BitFlight <25075504+Jamie-BitFlight@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 22, 2026

please do another pass over the failing ci pipelines @copilot

Fixed in 1ab55b5. The remaining zizmor CI failure was help[dependabot-cooldown]default-days: 3 was below zizmor's minimum of 7. Also addressed all review comments in the same commit:

  • dependabot.yml: default-days → 7, simplified cooldown to single value, added open-pull-requests-limit: 5
  • dependabot-auto-merge.yml: permissions: {} at workflow level + specific permissions at job level (matching repo convention), added branches: ["**"] trigger filter, restored fetch-metadata step now used to skip auto-approve/merge for semver-major updates (those require manual review)

@Jamie-BitFlight Jamie-BitFlight merged commit 0c53372 into main Feb 22, 2026
8 checks passed
@Jamie-BitFlight Jamie-BitFlight deleted the copilot/setup-dependabot-auto-merge branch February 22, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants