@PR • Labeler triggered by dilaouid on branch chore/analytics-contact-send-lwd #107306
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: "[CI] - Labeler - PR" | ||
| run-name: "@PR • Labeler triggered by ${{ github.actor }} ${{ format('on branch {0}', github.head_ref) }}" | ||
| # pull_request_target is required for fork PR write access (label/fork tagging). | ||
| # No PR code is checked out, so the elevated token cannot execute attacker-controlled code. | ||
| on: | ||
| - pull_request_target # zizmor: ignore[dangerous-triggers] | ||
| jobs: | ||
| triage: | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: generate token | ||
| id: generate-token | ||
| uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # 2.2.1 | ||
| with: | ||
| app-id: ${{ secrets.GH_BOT_APP_ID }} | ||
| private-key: ${{ secrets.GH_BOT_PRIVATE_KEY }} | ||
| permission-pull-requests: write | ||
| - uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4 | ||
| with: | ||
| repo-token: ${{ steps.generate-token.outputs.token }} | ||
| - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | ||
| if: github.event.pull_request.head.repo.fork | ||
| with: | ||
| github-token: ${{ steps.generate-token.outputs.token }} | ||
| script: | | ||
| try { | ||
| const { data: rawLabels } = await github.rest.issues.listLabelsOnIssue({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| }) || []; | ||
| const labels = rawLabels.map(label => label.name) | ||
| console.log(labels) | ||
| if(labels.includes('fork')) { | ||
| return | ||
| } | ||
| await github.rest.issues.setLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| labels: [...labels, 'fork'] | ||
| }) | ||
| } catch(error) { | ||
| console.error(error) | ||
| } | ||