From 1ba4be38d040936ab04402f4f5a3ce047c1446bd Mon Sep 17 00:00:00 2001 From: Sanidhya Singh Date: Thu, 29 Aug 2024 17:47:04 +0530 Subject: [PATCH] impr(PR labels): automatically label PRs "waiting for review/update" (@sanidhyas3s) (#5830) !nuf --- .github/workflows/label-pr.yml | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/label-pr.yml diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml new file mode 100644 index 000000000..1d3720b5e --- /dev/null +++ b/.github/workflows/label-pr.yml @@ -0,0 +1,58 @@ +name: Update PR labels + +permissions: + contents: read + pull-requests: write + +on: + pull_request: + types: [review_requested, review_request_removed] + pull_request_review: + types: [submitted] + issue_comment: + types: [created] + +jobs: + update-pr-labels: + name: Update PR Labels Based on Events + runs-on: ubuntu-latest + steps: + - name: Remove "waiting for update" label if comment is by PR author or a review is requested + if: ${{ (github.event.issue.pull_request && github.event_name == 'issue_comment' && github.event.comment.user.login == github.event.issue.user.login) || (github.event.action == 'review_requested') }} + uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: waiting for update + env: + NUMBER: ${{ github.event.issue.number }} + + - name: Add "waiting for review" if a review is requested + if: github.event.action == 'review_requested' + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: waiting for review + env: + NUMBER: ${{ github.event.pull_request.number }} + + - name: Remove "waiting for review" label if review request is removed + if: github.event.action == 'review_request_removed' + uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: waiting for review + env: + NUMBER: ${{ github.event.issue.number }} + + - name: Add "waiting for update" if changes are requested + if: ${{(github.event_name == 'pull_request_review' && github.event.review.state == 'changes_requested')}} + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: waiting for update + env: + NUMBER: ${{ github.event.pull_request.number }} + + - name: Remove "waiting for review" label after review + if: ${{github.event_name == 'pull_request_review' }} + uses: actions-ecosystem/action-remove-labels@v1 + with: + labels: waiting for review + env: + NUMBER: ${{ github.event.issue.number }}