Skip OpenCode review for non-write actors#47
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a preflight gate to the OpenCode PR Review workflow so it only performs checkout and runs the OpenCode review when the triggering actor has sufficient repository permissions, and it logs permission lookup failures before treating them as “no permission”.
Changes:
- Add a “trigger user permissions” check step that queries the actor’s repository permission via the GitHub API (via
gh api). - Conditionally skip
actions/checkoutand the OpenCode review action unless the actor has write/admin access (with a fallback to “none” on lookup failure).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+41
to
+45
| if [[ "$permission" == "admin" || "$permission" == "write" ]]; then | ||
| echo "can_review=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "can_review=false" >> "$GITHUB_OUTPUT" | ||
| echo "Skipping OpenCode review because ${TRIGGER_USER} has ${permission} repository permission, not write/admin." |
|
No findings to report for this PR. The permission guard is correctly implemented:
No correctness, security, reliability, or maintenance risks identified in the change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Checks