Skip to content

ci: add write permissions and fork-PR guard to pr-checks workflow#25

Merged
groupthinking merged 5 commits intomainfrom
copilot/fix-pr-checks-permissions
Feb 7, 2026
Merged

ci: add write permissions and fork-PR guard to pr-checks workflow#25
groupthinking merged 5 commits intomainfrom
copilot/fix-pr-checks-permissions

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

PR validation workflow fails with Resource not accessible by integration when attempting to post comments via github.rest.issues.createComment, because the default GITHUB_TOKEN lacks write access.

  • Added top-level permissions block granting only issues: write (least-privilege, since the workflow only calls issues.createComment)
  • Added a fork-PR guard that checks pr.head.repo.full_name === pr.base.repo.full_name before attempting to comment, since fork PRs always receive a read-only GITHUB_TOKEN regardless of workflow permissions
  • For fork PRs, validation issues are logged as warnings in the workflow output so authors can still see what needs fixing
permissions:
  issues: write

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

@vercel
Copy link

vercel bot commented Feb 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
event-relay-web Error Error Feb 7, 2026 8:24am
v0-uvai Error Error Feb 7, 2026 8:24am

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing job in PR checks due to GitHub API error ci: add write permissions to pr-checks workflow Feb 7, 2026
Copilot AI requested a review from groupthinking February 7, 2026 06:42
@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🔍 PR Validation

⚠️ PR title should follow conventional commits format

1 similar comment
@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🔍 PR Validation

⚠️ PR title should follow conventional commits format

@groupthinking groupthinking marked this pull request as ready for review February 7, 2026 07:25
Copilot AI review requested due to automatic review settings February 7, 2026 07:25
Copy link
Contributor

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

Updates the PR validation GitHub Actions workflow to grant the GITHUB_TOKEN write access needed to post PR comments, addressing failures caused by insufficient default token permissions.

Changes:

  • Added a top-level permissions block to pr-checks.yml granting pull-requests: write and issues: write.

Comment on lines 2 to 7
on:
pull_request:
types: [opened, reopened, synchronize, edited]
permissions:
pull-requests: write
issues: write
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

Even with explicit workflow permissions, pull_request workflows from forked repos still get a read-only GITHUB_TOKEN, so comment posting can continue to fail with Resource not accessible by integration. If you expect fork PRs, consider guarding the comment call (skip for forks) or moving to pull_request_target with appropriate hardening.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a fork-PR guard in 3ded7e0 — the workflow now checks pr.head.repo.full_name === pr.base.repo.full_name before attempting to comment. Fork PRs skip the createComment call and instead log validation issues as warnings in the workflow output so authors can still see what needs fixing.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment on lines +5 to +6
permissions:
issues: write

This comment was marked as outdated.

@groupthinking
Copy link
Owner

@copilot apply changes based on the comments in this thread

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 7, 2026

@copilot apply changes based on the comments in this thread

Applied both review suggestions in 3ded7e0: removed pull-requests: write (only issues: write is needed), and added a fork-PR guard that skips createComment and logs validation issues as warnings instead.

Copilot AI changed the title ci: add write permissions to pr-checks workflow ci: add write permissions and fork-PR guard to pr-checks workflow Feb 7, 2026
body: comment
});
// Fork PRs get a read-only GITHUB_TOKEN; skip commenting to avoid errors
if (pr.head.repo.full_name === pr.base.repo.full_name) {

This comment was marked as outdated.

@groupthinking groupthinking merged commit c2a49bb into main Feb 7, 2026
14 checks passed
@groupthinking groupthinking deleted the copilot/fix-pr-checks-permissions branch February 7, 2026 09:19
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