Skip to content

Commit 5899f15

Browse files
committed
chore: add GH actions for issue open, close, comment, label events (#5310)
1 parent 65a03b6 commit 5899f15

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
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-community-response') || contains(github.event.issue.labels.*.name, 'pending-maintainer-response') || contains(github.event.issue.labels.*.name, 'pending-close-response-required') || contains(github.event.issue.labels.*.name, 'pending-release')|| contains(github.event.issue.labels.*.name, 'pending-triage')) }}
14+
steps:
15+
- name: remove unnecessary labels after closing
16+
shell: bash
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
ISSUE_NUMBER: ${{ github.event.issue.number }}
20+
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
21+
run: |
22+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-close-response-required" --remove-label "pending-community-response" --remove-label "pending-maintainer-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.

.github/workflows/issue_comment.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Issue Comment
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
adjust-labels:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
ISSUE_NUMBER: ${{ github.event.issue.number }}
15+
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
16+
steps:
17+
- name: remove pending-community-response when new comment received
18+
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) && !github.event.issue.pull_request }}
19+
shell: bash
20+
run: |
21+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-community-response"
22+
- name: add pending-maintainer-response when new community comment received
23+
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }}
24+
shell: bash
25+
run: |
26+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-maintainer-response"
27+
- name: remove pending-maintainer-response when new owner/member comment received
28+
if: ${{ contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }}
29+
shell: bash
30+
run: |
31+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-maintainer-response"

.github/workflows/issue_labeled.yml

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"]'), 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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Issue Opened
2+
on:
3+
issues:
4+
types: [opened]
5+
6+
jobs:
7+
add-issue-opened-labels:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
issues: write
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
ISSUE_NUMBER: ${{ github.event.issue.number }}
14+
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
15+
steps:
16+
- name: Add the pending-triage label
17+
shell: bash
18+
run: |
19+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-triage"
20+
- name: Add the pending-maintainer-response label
21+
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }}
22+
shell: bash
23+
run: |
24+
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-maintainer-response"
25+
26+
maintainer-opened:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
issues: write
30+
if: ${{ contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }}
31+
steps:
32+
- name: Post comment if maintainer opened.
33+
shell: bash
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
ISSUE_NUMBER: ${{ github.event.issue.number }}
37+
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
38+
run: |
39+
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."

0 commit comments

Comments
 (0)