diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 35766df591..b86d1ff769 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -6,6 +6,7 @@ name: "Pull Request Labeler" on: - pull_request_target +- issue_comment permissions: contents: read @@ -18,7 +19,46 @@ jobs: pull-requests: write steps: - uses: actions/labeler@e54e5b338fbd6e6cdb5d60f51c22335fc57c401e + if: github.event_name == 'pull_request_target' with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/labeler.yml sync-labels: "" # This is a workaround for issue 18671 + + - uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 + if: github.event_name == 'pull_request_target' + with: + script: | + await github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ["please-review"] + }) + for (const label of ["reviewed/needs-rework 🔨", + "ci-fails/needs-rework 🔥", + "ci-failure-appears-unrelated"]) { + try { + await github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: label, + }) + } catch (err) { + if (err.status != 404) { + throw err; + } + } + } + + - uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 + if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/please-review') + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ["please-review"] + })