-
Notifications
You must be signed in to change notification settings - Fork 105
NO-JIRA: chore(gha): add workflow to label PRs with "review-requested" on creation #1768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,25 @@ | ||||||||||||
--- | ||||||||||||
name: Add Review Requested Label | ||||||||||||
on: # yamllint disable-line rule:truthy | ||||||||||||
pull_request: | ||||||||||||
types: [opened] | ||||||||||||
|
||||||||||||
permissions: | ||||||||||||
pull-requests: write | ||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
|
||||||||||||
jobs: | ||||||||||||
add-label: | ||||||||||||
if: contains(github.event.pull_request.labels.*.name, 'konflux-nudge') == false | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add a second guard to avoid mislabeling konflux PRs. Relying solely on the presence of the - if: contains(github.event.pull_request.labels.*.name, 'konflux-nudge') == false
+ if: github.actor != 'red-hat-konflux' &&
+ !contains(github.event.pull_request.labels.*.name, 'konflux-nudge') Also simplified 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||
steps: | ||||||||||||
- name: Add review-requested label | ||||||||||||
uses: actions/github-script@v7 | ||||||||||||
with: | ||||||||||||
# language=javascript | ||||||||||||
script: | | ||||||||||||
await github.rest.issues.addLabels({ | ||||||||||||
owner: context.repo.owner, | ||||||||||||
repo: context.repo.repo, | ||||||||||||
issue_number: context.payload.pull_request.number, | ||||||||||||
labels: ['review-requested'] | ||||||||||||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Fork support: consider pull_request_target or skip forks.
With
pull_request
, PRs from forks get a read-only token and labeling will fail (“Resource not accessible by integration”). Two safe options:pull_request_target
(no checkout of fork code here, so safe), orpull_request
and skip forks to avoid failures.Example diffs:
Option A (preferred for labeling forks):
Option B (skip forks cleanly):
🏁 Script executed:
Length of output: 1331
Ensure forked PRs can be labeled
Your workflow currently triggers on
pull_request
, which provides a read-onlyGITHUB_TOKEN
for forked PRs—causing theaddLabels
call to fail. You can fix this by either:• Switching the trigger to
pull_request_target
(preferred), since it runs in the base repo with write permissions.• Or keeping
pull_request
and guarding the job to run only on non-forks.Locations to update:
.github/workflows/notify-team-to-review-pr.yml
– change theon:
block or the job’sif:
condition as shown below.Option A (preferred – write token on forks):
Option B (skip forks):
🤖 Prompt for AI Agents