Repository navigation
Feat: Easter egg #185
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 Labeler | ||
|
Check warning on line 1 in .github/workflows/pr-labeler.yml
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
| jobs: | ||
| label-by-files: | ||
| name: Label by Changed Files | ||
| if: github.event.pull_request.draft == false | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Label based on changed paths | ||
| uses: actions/labeler@v5 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| configuration-path: .github/labeler.yml | ||
| sync-labels: true | ||
| label-by-commits: | ||
| name: Label by Commit Messages | ||
| if: github.event.pull_request.draft == false | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Fetch PR commit messages | ||
| id: check-breaking | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const pull_number = context.payload.pull_request.number; | ||
| const commits = await github.paginate( | ||
| github.rest.pulls.listCommits, | ||
| { owner, repo, pull_number } | ||
| ); | ||
| const commitMessages = commits | ||
| .map(c => `${c.commit.message}`) | ||
| .join('\n'); | ||
| console.log('PR Commit Messages:\n', commitMessages); | ||
| const regex = /BREAKING[ \t]+CHANGE|breaking[ \t]+change|!:|feat!|fix!|refactor!|perf!|chore!/i; | ||
| const found = regex.test(commitMessages); | ||
| core.setOutput('found', found ? 'true' : 'false'); | ||
| - name: Add breaking-change label | ||
| if: steps.check-breaking.outputs.found == 'true' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const { owner, repo } = context.repo; | ||
| const issue_number = context.payload.pull_request.number; | ||
| await github.rest.issues.addLabels({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| labels: ["breaking-change"], | ||
| }); | ||
| core.info(`Added 'breaking-change' label to PR #${issue_number}`); | ||
| - name: Remove breaking-change label (if no longer applicable) | ||
| if: steps.check-breaking.outputs.found == 'false' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const { owner, repo } = context.repo; | ||
| const issue_number = context.payload.pull_request.number; | ||
| try { | ||
| await github.rest.issues.removeLabel({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| name: "breaking-change", | ||
| }); | ||
| core.info("Removed 'breaking-change' label (no longer applicable)."); | ||
| } catch (e) { | ||
| if (e.status !== 404) throw e; | ||
| } | ||