Skip to content

Fix Dependabot Milestone workflow by granting pull-requests: write#7110

Merged
amartinezfayo merged 1 commit into
spiffe:mainfrom
amartinezfayo:fix-dependabot-milestone-permissions
Jul 2, 2026
Merged

Fix Dependabot Milestone workflow by granting pull-requests: write#7110
amartinezfayo merged 1 commit into
spiffe:mainfrom
amartinezfayo:fix-dependabot-milestone-permissions

Conversation

@amartinezfayo

Copy link
Copy Markdown
Member

The Dependabot Milestone workflow has failed on every Dependabot pull request since it was introduced. The job runs to completion, resolves the target milestone, and then fails on the final step that sets the milestone with gh: Resource not accessible by integration (HTTP 403).

The root cause is the workflow permissions block. It granted contents: read and issues: write, but declaring an explicit block sets every unlisted scope to none, including pull-requests. Setting a milestone on a Dependabot PR goes through the PATCH /repos/{repo}/issues/{n} REST endpoint, but because the target object is a pull request, GitHub checks the write against the pull-requests scope rather than issues, so issues: write alone is rejected.

This regressed in #7070, which dropped the old dependabot_automerge.yml workflow and moved the milestone logic into the standalone dependabot_milestone.yml. The milestone call is unchanged, but the old workflow granted pull-requests: write (alongside contents: write and issues: write), and the new workflow carried over issues: write while dropping the pull-requests: write scope that the call actually needs.

This is not the Dependabot read-only token restriction. The workflow uses pull_request_target with a base ref on main, so the run gets a write-capable token and secrets are available, which is why the read API calls earlier in the job succeed.

This PR replaces issues: write with pull-requests: write. The workflow only ever writes to a Dependabot pull request, so issues: write was never exercised and is dropped.

An example of a failure is here: https://github.com/spiffe/spire/actions/runs/28531397631

Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
@amartinezfayo
amartinezfayo requested a review from evan2645 as a code owner July 1, 2026 17:38
Copilot AI review requested due to automatic review settings July 1, 2026 17:38
@amartinezfayo amartinezfayo added this to the 1.15.2 milestone Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes the Dependabot Milestone GitHub Actions workflow so it can successfully assign a milestone to Dependabot pull requests by adjusting the workflow token permissions.

Changes:

  • Updates the workflow permissions to grant pull-requests: write (with explanatory comments) so the milestone assignment PATCH can succeed for PR targets.
  • Adjusts the job comment to reflect the pull_request_target execution context and token capabilities.

Comment thread .github/workflows/dependabot_milestone.yml
@amartinezfayo
amartinezfayo added this pull request to the merge queue Jul 2, 2026
Merged via the queue into spiffe:main with commit dbbbaf6 Jul 2, 2026
58 checks passed
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