-
Notifications
You must be signed in to change notification settings - Fork 8
try using another api for checking #53
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughReworked PR-label sync to use collaborator permission checks (admin/maintain → Changes
Sequence Diagram(s)sequenceDiagram
participant PR as Pull Request
participant Runner as Actions Runner
participant API as GitHub API
participant Repo as Repository Labels
PR->>Runner: trigger (pull_request_target)
Runner->>API: getCollaboratorPermissionLevel(author)
API-->>Runner: permission (admin/maintain | other)
alt maintainer (admin/maintain)
Runner->>Repo: add "org-member" label (use LABELLER_TOKEN)
else non-maintainer
Runner->>API: fetch commit count for author
API-->>Runner: commit count
alt first-time contributor (≤1)
Runner->>Repo: add "first-time-contributor"
else repeat contributor
Runner->>Repo: add "repeat-contributor"
end
end
Runner->>Repo: update PR labels / log result
sequenceDiagram
participant Trigger as Manual / Push
participant Runner as Actions Runner
participant API as GitHub API
participant Repo as Repository Labels
Trigger->>Runner: run setup-labels workflow
Runner->>API: list existing labels (paginated)
API-->>Runner: existing labels
loop for each desired label
Runner->>API: compare/create/update label (color/description)
API-->>Runner: created / updated / skipped / failed
end
Runner->>Repo: output summary (created/updated/skipped/failed)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/sync-pr-labels.yml (1)
265-277: Fix first‑time contributor threshold (≤1 mislabels prior contributors).
repos.listCommitsreturns commits from the default branch. When filtering byauthor: prAuthor, a user with exactly one prior commit will still be mislabeled as first-time due to the<= 1condition. Use=== 0to detect only users with no prior commits (optionally addper_page: 2to avoid fetching unnecessary data).🔧 Proposed fix
- const commits = await github.rest.repos.listCommits({ + const commits = await github.rest.repos.listCommits({ owner: context.repo.owner, repo: context.repo.repo, - author: prAuthor + author: prAuthor, + per_page: 2 }); @@ - if (commits.data.length <= 1) { + if (commits.data.length === 0) { contributorLabels.push('first-time-contributor'); } else { contributorLabels.push('external-contributor'); }
🤖 Fix all issues with AI agents
In @.github/workflows/sync-pr-labels.yml:
- Around line 281-289: The permission check for labeling maintainers uses the
wrong API value: when calling github.rest.repos.getCollaboratorPermissionLevel
(result stored in permissionLevel) the permission field returns "write" for
maintain-role users, not "maintain", so update the conditional that pushes into
contributorLabels (currently checking ['admin','maintain']) to check for
['admin','write'] instead, or alternatively inspect
permissionLevel.data.role_name if you need to distinguish the actual "maintain"
role; update the if that references permissionLevel.data.permission accordingly
and keep prAuthor and contributorLabels usage intact.
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/sync-pr-labels.yml:
- Around line 281-283: The PR uses non-existent labels: replace
contributorLabels.push('Org-Member') and any usage of 'external-contributor' in
the addLabels call with repository-defined labels (e.g., remove or replace
'Org-Member' with an appropriate existing label, and change
'external-contributor' to 'repeat-contributor'); update the logic around
contributorLabels and isMaintainer in the code that calls addLabels so it only
pushes valid labels (and/or create the 'Org-Member' label in repo config if you
intend to keep that name) to avoid silent failures from addLabels.
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.github/workflows/setup-labels.yml:
- Around line 189-203: Add a failing condition when any label operation failed:
after the existing summary block that references created/updated/skipped/failed,
check if failed > 0 and call core.setFailed(`Label setup failed: ${failed}
operations failed`) to mark the step as failed; keep the existing
success/complete console logs but ensure core.setFailed is invoked when failed >
0 (use the core import and the failed variable present in the script).
- Around line 138-145: The code uses github.rest.issues.listLabelsForRepo which
returns only the first page; replace that call with github.paginate to fetch all
labels (e.g., use github.paginate(github.rest.issues.listLabelsForRepo, { owner:
context.repo.owner, repo: context.repo.repo }) ), then derive existingLabelNames
from the combined result instead of the paged single response; update any uses
of existingLabels/existingLabelNames accordingly so no labels are missed and 422
errors are avoided.
…improve failure handling
| description: 'JavaScript/TypeScript code changes' | ||
| }, | ||
| { | ||
| name: 'python', |
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.
Not all repos contain Python code. Should we really have this label?
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.
GitHub auto-creates a label when we request GitHub bot to apply a label (if we not create that label), but those labels have no descriptions and all use the same color #ededed , see:
This setup explicitly defines a small, clean label set with proper descriptions and colors which include common language js, py
The main reason for introducing this workflow was the internal check pointing out the need for a contributor labels:
https://github.com/AOSSIE-Org/Template-Repo/actions/runs/21186875613/job/60943766803?pr=52
Language labels can always be adjusted per repo if needed
and also note that this is execute on workflow_dispatch means you need to manual trigger it for apply
Summary by CodeRabbit
New Features
Chores