Repository navigation
fix: update Go base image to version 1.25.12 #24
Workflow file for this run
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
| name: pr-size | |
| on: | |
| pull_request_target: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| permissions: | |
| pull-requests: write # add/remove labels on the PR (label op on a PR resource) | |
| issues: write # create the size/* label if it doesn't exist yet | |
| jobs: | |
| size-label: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const total = pr.additions + pr.deletions; | |
| // Thresholds match the reference: XS<10, S<50, M<200, L<500, XL<1000, XXL>=1000 | |
| const sizes = [ | |
| { name: "XS", max: 10, color: "3CBF00" }, | |
| { name: "S", max: 50, color: "5D9801" }, | |
| { name: "M", max: 200, color: "7F7203" }, | |
| { name: "L", max: 500, color: "A14C05" }, | |
| { name: "XL", max: 1000, color: "C32607" }, | |
| { name: "XXL", max: Infinity, color: "E50009" }, | |
| ]; | |
| const bucket = sizes.find((s) => total < s.max); | |
| const label = `size/${bucket.name}`; | |
| const { owner, repo } = context.repo; | |
| // Create the label with the desired color if it doesn't already exist. | |
| try { | |
| await github.rest.issues.getLabel({ owner, repo, name: label }); | |
| } catch (e) { | |
| if (e.status === 404) { | |
| await github.rest.issues.createLabel({ | |
| owner, repo, name: label, color: bucket.color, | |
| description: `PR size: ${bucket.name}`, | |
| }); | |
| } else { | |
| throw e; | |
| } | |
| } | |
| // Remove stale size/* labels, then apply the correct one. | |
| const current = pr.labels | |
| .map((l) => l.name) | |
| .filter((n) => n.startsWith("size/")); | |
| for (const name of current) { | |
| if (name !== label) { | |
| await github.rest.issues | |
| .removeLabel({ owner, repo, issue_number: pr.number, name }) | |
| .catch(() => {}); | |
| } | |
| } | |
| if (!current.includes(label)) { | |
| await github.rest.issues.addLabels({ | |
| owner, repo, issue_number: pr.number, labels: [label], | |
| }); | |
| } | |
| core.info(`PR #${pr.number}: ${total} lines changed -> ${label}`); |