generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 475
ci: add pr size labeler #1082
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
Merged
dbschmigelski
merged 12 commits into
strands-agents:main
from
dbschmigelski:pr-size-labeler
Oct 24, 2025
Merged
ci: add pr size labeler #1082
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9dbbc79
ci: add pr size labeler
dbschmigelski 2063c0f
Update pr-size-labeler.yml
dbschmigelski 1487b37
Update pr-size-labeler.yml
dbschmigelski cc497dc
Update pr-size-labeler.yml
dbschmigelski bfff42c
Update pr-size-labeler.yml
dbschmigelski 95da1e3
Update pr-size-labeler.yml
dbschmigelski 662a72f
Update pr-size-labeler.yml
dbschmigelski 91ab1b5
Update pr-size-labeler.yml
dbschmigelski 66c6a08
Update pr-size-labeler.yml
dbschmigelski c98c2cf
Update pr-size-labeler.yml
dbschmigelski 91fe28c
Update pr-size-labeler.yml
dbschmigelski 5500fda
Update pr-size-labeler.yml
dbschmigelski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: PR Size Labeler | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| branches: main | ||
|
|
||
| jobs: | ||
| label-size: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| issues: write | ||
| steps: | ||
| - name: Calculate PR size and apply label | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const pr = context.payload.pull_request; | ||
| const totalChanges = pr.additions + pr.deletions; | ||
|
|
||
| // Remove existing size labels | ||
| const labels = await github.rest.issues.listLabelsOnIssue({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number | ||
| }); | ||
|
|
||
| for (const label of labels.data) { | ||
| if (label.name.startsWith('size/')) { | ||
| await github.rest.issues.removeLabel({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| name: label.name | ||
| }); | ||
pgrayy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| // Determine and apply new size label | ||
| let sizeLabel; | ||
| if (totalChanges <= 20) sizeLabel = 'size/xs'; | ||
| else if (totalChanges <= 100) sizeLabel = 'size/s'; | ||
| else if (totalChanges <= 500) sizeLabel = 'size/m'; | ||
| else if (totalChanges <= 1000) sizeLabel = 'size/l'; | ||
| else { | ||
| sizeLabel = 'size/xl'; | ||
| } | ||
|
|
||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| labels: [sizeLabel] | ||
| }); | ||
|
|
||
| if (sizeLabel === 'size/xl') { | ||
| core.setFailed(`PR is too large (${totalChanges} lines). Please split into smaller PRs.`); | ||
pgrayy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.