From 0615cba65db9fd2597cd798a67e7a7fcfeacf5b4 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 4 Nov 2024 15:39:57 -0500 Subject: [PATCH] Automate some GitHub PR status labels manipulations - Set/remove "Work in Progress"/"Code Review Needed" for drafts. - Remove "Accepted", "Inactive", "Revision Needed" and "Stale" on pushes and reopens. I hope this reduce chances of PRs being forgotten after requested modifications done due to stale labels. It is better to have no labels than incorrect ones saying there is nothing to look at. Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. --- .github/workflows/labels.yml | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/labels.yml diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 000000000000..f8902bcb9d5e --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,45 @@ +name: labels + +on: + pull_request: + types: [ opened, synchronize, reopened, converted_to_draft, ready_for_review ] + +permissions: + pull-requests: write + +jobs: + open: + runs-on: ubuntu-latest + if: ${{ github.event.action == "opened" && github.event.pull_request.draft }} + steps: + - run: gh pr edit $ISSUE --add-label "Status: Work in Progress" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.pull_request.html_url }} + + push: + runs-on: ubuntu-latest + if: ${{ github.event.action == "synchronize" || github.event.action == "reopened" }} + steps: + - run: gh pr edit $ISSUE --remove-label "Status: Accepted,Status: Inactive,Status: Revision Needed,Status: Stale" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.pull_request.html_url }} + + draft: + runs-on: ubuntu-latest + if: ${{ github.event.action == "converted_to_draft" }} + steps: + - run: gh pr edit $ISSUE --remove-label "Status: Accepted,Status: Code Review Needed,Status: Inactive,Status: Revision Needed,Status: Stale" --add-label "Status: Work in Progress" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.pull_request.html_url }} + + rfr: + runs-on: ubuntu-latest + if: ${{ github.event.action == "ready_for_review" }} + steps: + - run: gh pr edit $ISSUE --remove-label "Status: Accepted,Status: Inactive,Status: Revision Needed,Status: Stale,Status: Work in Progress" --add-label "Status: Code Review Needed" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.pull_request.html_url }}