Skip to content

ci(auto-merge): grant issues:write and merge before commenting#69

Merged
cdhagmann merged 1 commit into
mainfrom
claude/busy-sanderson-322767
May 18, 2026
Merged

ci(auto-merge): grant issues:write and merge before commenting#69
cdhagmann merged 1 commit into
mainfrom
claude/busy-sanderson-322767

Conversation

@cdhagmann

@cdhagmann cdhagmann commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

Auto-merge of #68 (a fork PR) failed because the workflow's gh pr comment was denied (GraphQL: Resource not accessible by integration (addComment)). The workflow declared pull-requests: write but not issues: write, and gh pr comment posts via the GraphQL addComment mutation, which is enforced under the issues scope. set -euo pipefail then aborted the step before gh pr merge ran. This grants issues: write, reorders the step so merge runs before the celebratory comment, and makes that comment best-effort.

Linked issue / ADR

No issue — surfaced by the failed run on PR #68. No ADR: this is workflow plumbing, not an architectural change.

Working agreement

  • Single concern (workflow permission + ordering fix; no unrelated changes)
  • bin/rubocop and bin/rspec pass locally — N/A, workflow-only change with no Ruby diff
  • New behavior has a test; bug fix has a regression test — N/A, GitHub Actions workflows aren't unit-tested in this repo; verification is end-to-end (see Test plan)
  • Async work goes through Rooibos Commands — N/A, no Ruby code changed

Test plan

End-to-end: once this lands on main, the pull_request_target workflow re-runs against the base-branch version on the next synchronize event, so the fix applies retroactively to PR #68. Plan:

  1. Merge this PR.
  2. Close-and-reopen #68 (or push a no-op commit to Matt's branch) to retrigger validate-and-merge.
  3. Expected: lint passes (✓ 2 entries, all valid was already green), then gh pr merge --squash --delete-branch succeeds, then the "🎉 Thanks…" comment posts.
  4. If the comment regresses again, || true keeps the merge effective — check the run log for permission drift.

Notes for reviewer

  • Considered flipping the repo-wide default_workflow_permissions from read to write, but per-workflow declarations are the more conservative path and match the rest of the repo.
  • The same issues: write permission also benefits the if: failure() "validation failure" comment step in this workflow, which would have hit the same denial.

🤖 Generated with Claude Code

PR #68 (from a fork) passed lint but failed to auto-merge because
`gh pr comment` was denied:

  GraphQL: Resource not accessible by integration (addComment)

The repo's default workflow token is read-only, and this workflow
declared `pull-requests: write` but not `issues: write`. `gh pr comment`
uses the GraphQL `addComment` mutation, which is enforced under the
`issues` scope (PR comments are stored as issue comments). With
`set -euo pipefail`, the failed comment aborted the step before
`gh pr merge` ever ran.

Fixes:
- Add `issues: write` so the comment calls work on fork PRs.
- Run `gh pr merge` *before* the celebratory comment, so a future
  comment-permission regression cannot block a clean merge.
- Make the celebratory comment best-effort (`|| true`).

Verification: once on main, the workflow re-runs against the base-branch
version on the next `synchronize`. Closing and reopening PR #68 will
retrigger it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown

✅ PR template check passed. Thanks for filling out the template.

@cdhagmann cdhagmann merged commit 2ce68bc into main May 18, 2026
2 of 3 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.

1 participant