Skip to content

Commit 30ddf71

Browse files
authored
chore: Add label management & PR notification workflows (#121)
1 parent fbd75b4 commit 30ddf71

File tree

6 files changed

+153
-18
lines changed

6 files changed

+153
-18
lines changed

.github/workflows/issue_closed.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Issue Closed
2+
3+
on:
4+
issues:
5+
types: [closed]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
cleanup-labels:
12+
runs-on: ubuntu-latest
13+
if: ${{ (contains(github.event.issue.labels.*.name, 'pending-response') || contains(github.event.issue.labels.*.name, 'closing soon') || contains(github.event.issue.labels.*.name, 'pending-release')|| contains(github.event.issue.labels.*.name, 'pending-triage')) }}
14+
steps:
15+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
16+
- name: remove unnecessary labels after closing
17+
shell: bash
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
ISSUE_NUMBER: ${{ github.event.issue.number }}
21+
run: |
22+
gh issue edit $ISSUE_NUMBER --remove-label "closing soon" --remove-label "pending-response" --remove-label "pending-release" --remove-label "pending-triage"
23+
24+
comment-visibility-warning:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: aws-actions/closed-issue-message@36b7048ea77bb834d16e7a7c5b5471ac767a4ca1 # v1
28+
with:
29+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
30+
message: |
31+
This issue is now closed. Comments on closed issues are hard for our team to see.
32+
If you need more assistance, please open a new issue that references this one.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Issue Comment
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
notify:
9+
runs-on: ubuntu-latest
10+
permissions: {}
11+
if: ${{ !github.event.issue.pull_request && !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }}
12+
steps:
13+
- name: Run webhook curl command
14+
env:
15+
WEBHOOK_URL: ${{ secrets.SLACK_COMMENT_WEBHOOK_URL }}
16+
BODY: ${{ toJson(github.event.comment.body) }}
17+
COMMENT_URL: ${{github.event.comment.html_url}}
18+
shell: bash
19+
run: echo $BODY | xargs -I {} curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data '{"body":"{}", "issue":"'$COMMENT_URL'"}'
20+
21+
remove-pending-response-label:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
issues: write
25+
if: ${{ !github.event.issue.pull_request && contains(github.event.issue.labels.*.name, 'pending-response') }}
26+
steps:
27+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
28+
- name: remove unnecessary labels after closing
29+
shell: bash
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
ISSUE_NUMBER: ${{ github.event.issue.number }}
33+
run: |
34+
gh issue edit $ISSUE_NUMBER --remove-label "pending-response"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Issue Labeled
2+
on:
3+
issues:
4+
types: [labeled]
5+
6+
jobs:
7+
remove-pending-triage-label:
8+
runs-on: ubuntu-latest
9+
if: ${{ contains(fromJSON('["question", "bug", "feature-request", "improvement"]'), github.event.label.name) }}
10+
permissions:
11+
issues: write
12+
steps:
13+
- name: Remove the pending-triage label
14+
shell: bash
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
ISSUE_NUMBER: ${{ github.event.issue.number }}
18+
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
19+
run: |
20+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-triage"

.github/workflows/issue_opened.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Issue Opened
2+
on:
3+
issues:
4+
types: [opened]
5+
6+
jobs:
7+
notify:
8+
runs-on: ubuntu-latest
9+
permissions: {}
10+
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }}
11+
steps:
12+
- name: Run webhook curl command
13+
env:
14+
WEBHOOK_URL: ${{ secrets.SLACK_ISSUE_WEBHOOK_URL }}
15+
ISSUE: ${{toJson(github.event.issue.title)}}
16+
ISSUE_URL: ${{github.event.issue.html_url}}
17+
USER: ${{github.event.issue.user.login}}
18+
shell: bash
19+
run: echo $ISSUE | sed 's/[^a-zA-Z0-9 &().,:]//g' | xargs -I {} curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data '{"issue":"{}", "issueUrl":"'$ISSUE_URL'", "user":"'$USER'"}'
20+
21+
add-pending-triage-label:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
issues: write
25+
steps:
26+
- name: Add the pending-triage label
27+
shell: bash
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
ISSUE_NUMBER: ${{ github.event.issue.number }}
31+
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
32+
run: |
33+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-triage"
34+
35+
maintainer-opened:
36+
runs-on: ubuntu-latest
37+
permissions:
38+
issues: write
39+
if: ${{ contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }}
40+
steps:
41+
- name: Post comment if maintainer opened.
42+
shell: bash
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
ISSUE_NUMBER: ${{ github.event.issue.number }}
46+
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
47+
run: |
48+
gh issue comment $ISSUE_NUMBER --repo $REPOSITORY_NAME -b "This issue was opened by a maintainer of this repository; updates will be posted here. If you are also experiencing this issue, please comment here with any relevant information so that we're aware and can prioritize accordingly."

.github/workflows/notify_comments.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Notify Pull Request
2+
3+
on:
4+
pull_request:
5+
types: [opened, ready_for_review, reopened]
6+
7+
jobs:
8+
notify:
9+
runs-on: ubuntu-latest
10+
if: ${{ !github.event.draft }}
11+
steps:
12+
- name: Run webhook curl command
13+
env:
14+
WEBHOOK_URL: ${{ secrets.SLACK_PR_WEBHOOK_URL }}
15+
URL: ${{ github.event.pull_request.html_url }}
16+
TITLE: ${{ github.event.pull_request.title }}
17+
USER: ${{ github.event.pull_request.user.login }}
18+
shell: bash
19+
run: curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data "{\"url\":\"$URL\", \"title\":\"$TITLE\", \"user\":\"$USER\"}"

0 commit comments

Comments
 (0)