From: Daan De Meyer Date: Thu, 8 Dec 2022 15:25:03 +0000 (+0100) Subject: ci: Add/Drop labels on pull request activity and comment X-Git-Tag: v253-rc1~329 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8fc78e6845cbc1796573fd8057f275c5149f3a27;p=thirdparty%2Fsystemd.git ci: Add/Drop labels on pull request activity and comment When a pull request is opened/updated, add "please-review" and remove a few other labels. When a comment is made with /please-review on a PR. Add the "please-review" label to the PR. --- diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 35766df5915..b86d1ff7692 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"] + })