From ff4c1ab982a5356c4e849ef622a8de8c36541290 Mon Sep 17 00:00:00 2001 From: Alex Welsh Date: Wed, 27 May 2026 11:00:50 +0100 Subject: [PATCH] Move labelling automation to new file, improve logic --- .../stackhpc-pull-request-labels.yml | 40 +++++++++++++++++++ .github/workflows/stackhpc-pull-request.yml | 14 ------- 2 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/stackhpc-pull-request-labels.yml diff --git a/.github/workflows/stackhpc-pull-request-labels.yml b/.github/workflows/stackhpc-pull-request-labels.yml new file mode 100644 index 000000000..a7452eea9 --- /dev/null +++ b/.github/workflows/stackhpc-pull-request-labels.yml @@ -0,0 +1,40 @@ +name: Auto-label Pull Requests +'on': + pull_request: + types: + - opened + - reopened + - ready_for_review + - converted_to_draft + +jobs: + auto-label: + runs-on: ubuntu-latest + if: github.repository == 'stackhpc/stackhpc-kayobe-config' + permissions: + pull-requests: write + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + steps: + + - name: Add waiting-review label (New Ready PR) + if: (github.event.action == 'opened' || github.event.action == 'reopened') && github.event.pull_request.draft == false + run: gh pr edit "$PR_NUMBER" --add-label "waiting-review" + + - name: Add waiting-author-response label (New Draft PR) + if: (github.event.action == 'opened' || github.event.action == 'reopened') && github.event.pull_request.draft == true + run: gh pr edit "$PR_NUMBER" --add-label "waiting-author-response" + + - name: Switch labels when PR becomes Ready for Review + if: github.event.action == 'ready_for_review' + run: | + gh pr edit "$PR_NUMBER" --remove-label "waiting-author-response" || true + gh pr edit "$PR_NUMBER" --add-label "waiting-review" + + - name: Switch labels when PR is converted back to Draft + if: github.event.action == 'converted_to_draft' + run: | + gh pr edit "$PR_NUMBER" --remove-label "waiting-review" || true + gh pr edit "$PR_NUMBER" --add-label "waiting-author-response" diff --git a/.github/workflows/stackhpc-pull-request.yml b/.github/workflows/stackhpc-pull-request.yml index 5e280fa63..b98470619 100644 --- a/.github/workflows/stackhpc-pull-request.yml +++ b/.github/workflows/stackhpc-pull-request.yml @@ -8,20 +8,6 @@ name: Pull request 'on': pull_request: jobs: - # Label all newly-opened PRs as "waiting-review" - auto-label: - runs-on: ubuntu-latest - if: github.event.action == 'opened' && github.repository == 'stackhpc/stackhpc-kayobe-config' - permissions: - pull-requests: write - steps: - - name: Add waiting-review label - run: gh pr edit "$PR_NUMBER" --add-label "waiting-review" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - PR_NUMBER: ${{ github.event.pull_request.number }} - # Detect which files have changed and use this to run jobs conditionally. # Note that we can't use the workflow-level paths attribute since this # would skip the workflow entirely, and would prevent us from making the