diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 32d1037184..f403c1030c 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -3,6 +3,8 @@ name: Labeler on: pull_request_target: types: [opened, synchronize, reopened] + issues: + types: [opened] permissions: {} @@ -23,3 +25,56 @@ jobs: configuration-path: .github/labeler.yml repo-token: ${{ steps.app-token.outputs.token }} sync-labels: true + - name: Apply maintainer label for org members + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 + with: + github-token: ${{ steps.app-token.outputs.token }} + script: | + const association = context.payload.pull_request?.author_association; + if (!association) { + return; + } + if (![ + "MEMBER", + "OWNER", + ].includes(association)) { + return; + } + + await github.rest.issues.addLabels({ + ...context.repo, + issue_number: context.payload.pull_request.number, + labels: ["maintainer"], + }); + + label-issues: + permissions: + issues: write + runs-on: ubuntu-latest + steps: + - uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1 + id: app-token + with: + app-id: "2729701" + private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} + - name: Apply maintainer label for org members + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 + with: + github-token: ${{ steps.app-token.outputs.token }} + script: | + const association = context.payload.issue?.author_association; + if (!association) { + return; + } + if (![ + "MEMBER", + "OWNER", + ].includes(association)) { + return; + } + + await github.rest.issues.addLabels({ + ...context.repo, + issue_number: context.payload.issue.number, + labels: ["maintainer"], + });