Skip to content

Automate Dependabot PR handling with Copilot coding agent - #2732

Merged
Akanksha Jain (jainakanksha-msft) merged 3 commits into
mainfrom
dependabot-copilot-automation
Aug 13, 2026
Merged

Automate Dependabot PR handling with Copilot coding agent#2732
Akanksha Jain (jainakanksha-msft) merged 3 commits into
mainfrom
dependabot-copilot-automation

Conversation

@jainakanksha-msft

@jainakanksha-msft Akanksha Jain (jainakanksha-msft) commented Aug 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds copilot-dependabot-agent.yml + copilot-dependabot-instructions.md: posts a @copilot comment on every new/updated Dependabot PR asking Copilot's coding agent to do impact analysis, fix build/conflict issues, add/update tests, run the relevant test suites, update ChangeLog.md, address PR comments, self-rate the work, iterate to a 10/10, and post a summary — before the PR is ready for human review.
  • Adds dependabot-conflict-recheck.yml: after any merge to main, re-dispatches the Copilot agent on any open Dependabot PR that merge knocked into a conflicting state.

Auto-merge is intentionally left out of this PR — we'll watch a few iterations of Copilot's output on real Dependabot PRs first, then add an auto-merge workflow in a follow-up once we're comfortable with the quality.

Test plan

  • Wait for (or open) a real Dependabot PR and confirm the @copilot instructions comment is posted automatically
  • Confirm Copilot's agent commits show up on the PR and addresses the checklist
  • Merge an unrelated PR while a Dependabot PR is deliberately left conflicting; confirm the conflict-recheck workflow re-dispatches Copilot

Dependabot only bumps versions and can't fix breakage, add tests, or
update the changelog on its own. This wires in GitHub Copilot's coding
agent to do that work automatically, then auto-merges once CI passes
and a maintainer approves:

- dependabot-auto-merge.yml: approve and enable auto-merge for
  Dependabot PRs once required checks pass.
- copilot-dependabot-agent.yml: comment @copilot with a checklist
  (impact analysis, build/conflict fixes, tests, changelog, comment
  review, self-rating) on every new/updated Dependabot PR.
- dependabot-conflict-recheck.yml: after any merge to main, re-assign
  Copilot to any open Dependabot PR that now conflicts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 13, 2026 07:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 GitHub Actions workflows and a Copilot instruction template to automate handling of Dependabot PRs: dispatching Copilot’s coding agent to prepare PRs, re-dispatching when PRs become conflicting, and enabling squash auto-merge for Dependabot PRs after checks pass.

Changes:

  • Add an auto-merge workflow that approves Dependabot PRs and enables squash auto-merge.
  • Add a workflow that comments @copilot instructions on Dependabot PRs (and supports manual re-dispatch).
  • Add a post-merge recheck workflow that re-dispatches Copilot on any open Dependabot PRs that are now conflicting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/dependabot-auto-merge.yml Approves Dependabot PRs and enables squash auto-merge via gh once checks pass.
.github/workflows/copilot-dependabot-agent.yml Dispatches Copilot by posting a PR comment with the instruction template.
.github/copilot-dependabot-instructions.md Defines the standardized checklist Copilot should follow on Dependabot PRs.
.github/workflows/dependabot-conflict-recheck.yml On pushes to main, finds conflicting Dependabot PRs and re-dispatches the Copilot workflow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +21 to +23
gh pr list --repo "$GITHUB_REPOSITORY" --author "app/dependabot" --state open \
--json number,mergeable --jq '.[] | select(.mergeable == "CONFLICTING") | .number' \
| while read -r n; do
Comment on lines +14 to +18
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
Comment on lines +30 to +34
- name: Ask Copilot to work the PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.pr.outputs.number }}
run: gh pr comment "$PR_NUMBER" --body-file .github/copilot-dependabot-instructions.md
Hold off on auto-merge until the Copilot agent's output has been
reviewed over a few iterations of real Dependabot PRs.
Copilot AI review requested due to automatic review settings August 13, 2026 07:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (3)

.github/workflows/copilot-dependabot-agent.yml:34

  • gh pr comment ... --body-file .github/copilot-dependabot-instructions.md will fail because the workflow never checks out the repository, so the body file (and even the repo context for gh) is not available on the runner. Add a checkout step (or otherwise fetch the file), and pass --repo for robustness when not in a git worktree.
      - name: Ask Copilot to work the PR
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PR_NUMBER: ${{ steps.pr.outputs.number }}
        run: gh pr comment "$PR_NUMBER" --body-file .github/copilot-dependabot-instructions.md

.github/workflows/dependabot-conflict-recheck.yml:21

  • gh pr list --author "app/dependabot" is unlikely to match Dependabot PRs because --author filters by user, while Dependabot is a GitHub App. Use --app dependabot to reliably list Dependabot-authored PRs.
          gh pr list --repo "$GITHUB_REPOSITORY" --author "app/dependabot" --state open \

.github/workflows/copilot-dependabot-agent.yml:5

  • PR description says it adds dependabot-auto-merge.yml, but that workflow file is not present in this change set. Either add the missing workflow, or update the PR description so it matches what’s actually being proposed.
name: Copilot Dependabot Agent

on:
  pull_request:
    types: [opened, synchronize, reopened]

- copilot-dependabot-agent: checkout the repo before posting the
  instructions comment, since --body-file needs the file on disk;
  pin GH_REPO explicitly too.
- dependabot-conflict-recheck: match Dependabot PRs with --app
  dependabot instead of --author (it's a GitHub App, not a user),
  and set an explicit --limit so PRs past the default 30 aren't
  silently skipped.
Copilot AI review requested due to automatic review settings August 13, 2026 07:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (1)

.github/workflows/dependabot-conflict-recheck.yml:26

  • The gh pr list ... | while read ... pipeline can mask failures from gh pr list because GitHub Actions' default bash shell doesn't enable pipefail. If gh errors (auth/rate-limit/etc.), the step may still succeed and silently skip redispatching.
        run: |
          sleep 20
          gh pr list --repo "$GITHUB_REPOSITORY" --app dependabot --state open --limit 100 \
            --json number,mergeable --jq '.[] | select(.mergeable == "CONFLICTING") | .number' \
          | while read -r n; do

@jainakanksha-msft
Akanksha Jain (jainakanksha-msft) merged commit bee4e51 into main Aug 13, 2026
46 checks passed
@jainakanksha-msft
Akanksha Jain (jainakanksha-msft) deleted the dependabot-copilot-automation branch August 13, 2026 10:06
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.

2 participants