Skip to content

Commit 49bbd5a

Browse files
committed
ci(issues): added the issues auto-labeling pipeline
Signed-off-by: k4yt3x <i@k4yt3x.com>
1 parent e8b0b0e commit 49bbd5a

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/issues.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Issues
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
- reopened
8+
- closed
9+
10+
jobs:
11+
label_issues:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Remove all 'state:' labels
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
run: |
21+
ISSUE_NUMBER=${{ github.event.issue.number }}
22+
REPO=${{ github.repository }}
23+
EXISTING_LABELS=$(gh issue view $ISSUE_NUMBER --repo $REPO --json labels --jq '.labels[].name')
24+
25+
for label in $EXISTING_LABELS; do
26+
if [[ $label == state:* ]]; then
27+
gh issue edit $ISSUE_NUMBER --remove-label "$label" --repo $REPO
28+
fi
29+
done
30+
31+
- name: Add 'state:Backlog' label on issue opened or reopened
32+
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
LABEL_NAME="state:Backlog"
37+
REPO=${{ github.repository }}
38+
ISSUE_NUMBER=${{ github.event.issue.number }}
39+
40+
if gh label list --repo $REPO | grep -q "$LABEL_NAME"; then
41+
gh issue edit $ISSUE_NUMBER --add-label "$LABEL_NAME" --repo $REPO
42+
fi
43+
44+
- name: Add 'state:Done' label on issue closed
45+
if: ${{ github.event.action == 'closed' }}
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
LABEL_NAME="state:Done"
50+
REPO=${{ github.repository }}
51+
ISSUE_NUMBER=${{ github.event.issue.number }}
52+
53+
if gh label list --repo $REPO | grep -q "$LABEL_NAME"; then
54+
gh issue edit $ISSUE_NUMBER --add-label "$LABEL_NAME" --repo $REPO
55+
fi

0 commit comments

Comments
 (0)