feat(swift): add Swift Package Manager ecosystem support #217
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: Auto Label PRs | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| label: | |
| name: Label PR | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Auto-label based on changed files | |
| uses: actions/labeler@v5 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| configuration-path: .github/labeler.yml | |
| sync-labels: false | |
| - name: Add size label | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const additions = pr.additions; | |
| const deletions = pr.deletions; | |
| const totalChanges = additions + deletions; | |
| // Calculate size category | |
| let sizeLabel = ''; | |
| if (totalChanges < 10) { | |
| sizeLabel = 'size: XS'; | |
| } else if (totalChanges < 50) { | |
| sizeLabel = 'size: S'; | |
| } else if (totalChanges < 200) { | |
| sizeLabel = 'size: M'; | |
| } else if (totalChanges < 500) { | |
| sizeLabel = 'size: L'; | |
| } else if (totalChanges < 1000) { | |
| sizeLabel = 'size: XL'; | |
| } else { | |
| sizeLabel = 'size: XXL'; | |
| } | |
| // Remove old size labels | |
| const currentLabels = await github.rest.issues.listLabelsOnIssue({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number | |
| }); | |
| const sizeLabels = currentLabels.data | |
| .map(label => label.name) | |
| .filter(name => name.startsWith('size: ')); | |
| for (const label of sizeLabels) { | |
| if (label !== sizeLabel) { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| name: label | |
| }); | |
| } | |
| } | |
| // Add new size label | |
| if (!sizeLabels.includes(sizeLabel)) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| labels: [sizeLabel] | |
| }); | |
| } | |
| console.log(`PR #${pr.number}: +${additions} -${deletions} = ${totalChanges} changes → ${sizeLabel}`); |