Skip to content

Commit 5f4efcc

Browse files
committed
Move labelling automation to new file, improve logic
1 parent 3dcdc9d commit 5f4efcc

2 files changed

Lines changed: 40 additions & 14 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Auto-label Pull Requests
2+
'on':
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- ready_for_review
8+
- converted_to_draft
9+
10+
jobs:
11+
auto-label:
12+
runs-on: ubuntu-latest
13+
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
14+
permissions:
15+
pull-requests: write
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
GH_REPO: ${{ github.repository }}
19+
PR_NUMBER: ${{ github.event.pull_request.number }}
20+
steps:
21+
22+
- name: Add waiting-review label to new ready PRs
23+
if: (github.event.action == 'opened' || github.event.action == 'reopened') && github.event.pull_request.draft == false
24+
run: gh pr edit "$PR_NUMBER" --add-label "waiting-review"
25+
26+
- name: Add waiting-author-response label to new draft PRs
27+
if: (github.event.action == 'opened' || github.event.action == 'reopened') && github.event.pull_request.draft == true
28+
run: gh pr edit "$PR_NUMBER" --add-label "waiting-author-response"
29+
30+
- name: Switch labels when PR becomes Ready for Review
31+
if: github.event.action == 'ready_for_review'
32+
run: |
33+
gh pr edit "$PR_NUMBER" --remove-label "waiting-author-response" || true
34+
gh pr edit "$PR_NUMBER" --add-label "waiting-review"
35+
36+
- name: Switch labels when PR is converted to Draft
37+
if: github.event.action == 'converted_to_draft'
38+
run: |
39+
gh pr edit "$PR_NUMBER" --remove-label "waiting-review" || true
40+
gh pr edit "$PR_NUMBER" --add-label "waiting-author-response"

.github/workflows/stackhpc-pull-request.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ name: Pull request
88
'on':
99
pull_request:
1010
jobs:
11-
# Label all newly-opened PRs as "waiting-review"
12-
auto-label:
13-
runs-on: ubuntu-latest
14-
if: github.event.action == 'opened' && github.repository == 'stackhpc/stackhpc-kayobe-config'
15-
permissions:
16-
pull-requests: write
17-
steps:
18-
- name: Add waiting-review label
19-
run: gh pr edit "$PR_NUMBER" --add-label "waiting-review"
20-
env:
21-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
GH_REPO: ${{ github.repository }}
23-
PR_NUMBER: ${{ github.event.pull_request.number }}
24-
2511
# Detect which files have changed and use this to run jobs conditionally.
2612
# Note that we can't use the workflow-level paths attribute since this
2713
# would skip the workflow entirely, and would prevent us from making the

0 commit comments

Comments
 (0)