From 34de483649167355b2f663783dd1e1f5bdc5c170 Mon Sep 17 00:00:00 2001 From: Gauthier Petetin Date: Tue, 6 Jun 2023 10:01:58 +0200 Subject: [PATCH 1/2] feat(action): remove labels after PR closed --- .../remove_labels_after_pr_closed.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/remove_labels_after_pr_closed.yml diff --git a/.github/workflows/remove_labels_after_pr_closed.yml b/.github/workflows/remove_labels_after_pr_closed.yml new file mode 100644 index 00000000000..da5599604c6 --- /dev/null +++ b/.github/workflows/remove_labels_after_pr_closed.yml @@ -0,0 +1,39 @@ +name: Remove labels after PR closed + +on: + pull_request: + types: [closed] + +jobs: + cleanup: + runs-on: ubuntu-latest + + steps: + - name: Remove labels + env: + REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + run: | + LABELS=( + "product-backlog" + "needs-design" + "design-in-progress" + "ready-for-dev" + "sprint-backlog" + "in-progress" + "blocked" + "needs-dev-review" + "needs-qa" + "issues-found" + "ready-for-release" + ) + + for LABEL in "${LABELS[@]}"; do + curl \ + -X DELETE \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$LABEL" + done From b3707c55ed3fd6d8637da4d978b5b88d170d59ab Mon Sep 17 00:00:00 2001 From: Gauthier Petetin Date: Tue, 6 Jun 2023 10:17:47 +0200 Subject: [PATCH 2/2] fix(action): support issues as well --- .github/workflows/remove_labels_after_pr_closed.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/remove_labels_after_pr_closed.yml b/.github/workflows/remove_labels_after_pr_closed.yml index da5599604c6..68d8921c576 100644 --- a/.github/workflows/remove_labels_after_pr_closed.yml +++ b/.github/workflows/remove_labels_after_pr_closed.yml @@ -1,6 +1,8 @@ -name: Remove labels after PR closed +name: Remove labels after issue (or PR) closed on: + issues: + types: [closed] pull_request: types: [closed] @@ -12,7 +14,7 @@ jobs: - name: Remove labels env: REPO: ${{ github.repository }} - PR_NUMBER: ${{ github.event.pull_request.number }} + ISSUE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -35,5 +37,5 @@ jobs: -X DELETE \ -H "Authorization: token $GITHUB_TOKEN" \ -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/$LABEL" + "https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/$LABEL" done