feat: remove existing size labels before adding new #23
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 Labeler | |
| on: # yamllint disable-line rule:truthy | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| size-label: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Remove existing size labels | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const sizeLabels = ['size/XS', 'size/S', 'size/M', 'size/L', 'size/XL']; | |
| const { data: labels } = await github.rest.issues.listLabelsOnIssue({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| for (const label of labels) { | |
| if (sizeLabels.includes(label.name)) { | |
| console.log(`Removing existing size label: ${label.name}`); | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| name: label.name, | |
| }); | |
| } | |
| } | |
| - name: Label PR based on size | |
| uses: codelytv/pr-size-labeler@v1 | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| xs_label: "size/XS" | |
| xs_max_size: 10 | |
| s_label: "size/S" | |
| s_max_size: 30 | |
| m_label: "size/M" | |
| m_max_size: 100 | |
| l_label: "size/L" | |
| l_max_size: 500 | |
| xl_label: "size/XL" | |
| fail_if_xl: false | |
| message_if_xl: > | |
| This PR is very large. Consider breaking it down into smaller PRs | |
| for easier review and better maintainability. | |
| files_to_ignore: | | |
| package-lock.json | |
| yarn.lock | |
| pnpm-lock.yaml | |
| Cargo.lock | |
| composer.lock | |
| Pipfile.lock | |
| poetry.lock | |
| *.min.js | |
| *.min.css | |
| *.map | |
| dist/* | |
| build/* | |
| __pycache__/* | |
| *.pyc |