Skip to content

Commit 0523556

Browse files
committed
maint: rewrite workflows to get mail notifications upon setting labels
Signed-off-by: Yury V. Zaytsev <[email protected]>
1 parent 6b8b45f commit 0523556

File tree

4 files changed

+82
-59
lines changed

4 files changed

+82
-59
lines changed

.github/workflows/command-approve.yml

-54
This file was deleted.
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Approve issue
2+
3+
on:
4+
issues:
5+
types: [ labeled ]
6+
workflow_dispatch:
7+
inputs:
8+
issue_number:
9+
description: Issue number
10+
required: true
11+
type: number
12+
13+
jobs:
14+
approve-issue:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 5
17+
18+
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment
19+
if: ${{ !github.event.issue.pull_request && ((contains(github.event.pull_request.labels.*.name, 'approved') && contains('OWNER MEMBER COLLABORATOR', github.event.comment.author_association)) || inputs.issue_number != '') }}
20+
21+
permissions:
22+
issues: write
23+
24+
steps:
25+
- run: |
26+
gh issue edit \
27+
${{ inputs.issue_number != '' && inputs.issue_number || github.event.issue.number }} \
28+
--remove-label "state: in review"
29+
30+
gh issue comment \
31+
${{ inputs.issue_number != '' && inputs.issue_number || github.event.issue.number }} \
32+
--body "The changes in the branch associated with this issue have been approved."
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
GH_REPO: ${{ github.repository }}

.github/workflows/command-review.yml renamed to .github/workflows/issue-label-review.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Review command
1+
name: Review issue
22

33
on:
4-
issue_comment:
5-
types: [ created, edited ]
4+
issues:
5+
types: [ labeled ]
66
workflow_dispatch:
77
inputs:
88
issue_number:
@@ -16,7 +16,7 @@ jobs:
1616
timeout-minutes: 5
1717

1818
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment
19-
if: ${{ !github.event.issue.pull_request && ((github.event.comment.body == '/review' && contains('OWNER MEMBER COLLABORATOR', github.event.comment.author_association)) || inputs.issue_number != '') }}
19+
if: ${{ !github.event.issue.pull_request && ((contains(github.event.pull_request.labels.*.name, 'review') && contains('OWNER MEMBER COLLABORATOR', github.event.comment.author_association)) || inputs.issue_number != '') }}
2020

2121
permissions:
2222
issues: write
@@ -25,7 +25,11 @@ jobs:
2525
- run: |
2626
gh issue edit \
2727
${{ inputs.issue_number != '' && inputs.issue_number || github.event.issue.number }} \
28-
--add-label "state: in review"
28+
--remove-label "state: approved"
29+
30+
gh issue comment \
31+
${{ inputs.issue_number != '' && inputs.issue_number || github.event.issue.number }} \
32+
--body "The changes in the branch associated with this issue are ready for review."
2933
env:
3034
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3135
GH_REPO: ${{ github.repository }}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Approve PR
2+
3+
on:
4+
pull_request:
5+
types: [ labeled ]
6+
workflow_dispatch:
7+
inputs:
8+
issue_number:
9+
description: Issue number
10+
required: true
11+
type: number
12+
13+
jobs:
14+
approve-pr:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 5
17+
18+
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issue_comment
19+
if: ${{ github.event.issue.pull_request && ((contains(github.event.pull_request.labels.*.name, 'approved') && contains('OWNER MEMBER COLLABORATOR', github.event.comment.author_association)) || inputs.issue_number != '') }}
20+
21+
permissions:
22+
pull-requests: write
23+
24+
# https://github.com/cli/cli/issues/6274
25+
repository-projects: read
26+
27+
steps:
28+
- run: |
29+
gh pr review \
30+
${{ inputs.issue_number != '' && inputs.issue_number || github.event.issue.number }} \
31+
--approve
32+
33+
gh pr edit \
34+
${{ inputs.issue_number != '' && inputs.issue_number || github.event.issue.number }} \
35+
--remove-label "state: in review"
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
GH_REPO: ${{ github.repository }}

0 commit comments

Comments
 (0)