Skip to content

Commit ed95884

Browse files
committed
feat: label issues
1 parent b13127d commit ed95884

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/label-issues.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Label issues
2+
on:
3+
issues:
4+
types:
5+
- opened
6+
- reopened
7+
jobs:
8+
label_issues:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Get issue details
17+
id: get_issue_details
18+
run: |
19+
ISSUE_BODY=$(gh issue view ${{ github.event.issue.number }} --json body -q .body)
20+
echo "::set-output name=body::$ISSUE_BODY"
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Determine labels
25+
id: determine_labels
26+
run: |
27+
CLEANED_BODY="${{ steps.get_issue_details.outputs.body }}"
28+
CLEANED_BODY=$(echo "$CLEANED_BODY" | sed 's/_No response_//g')
29+
CLEANED_BODY=$(echo "$CLEANED_BODY" | xargs)
30+
LABELS=""
31+
32+
if [[ "$CLEANED_BODY" == *"Core"* ]]; then
33+
LABELS="core"
34+
elif [[ "$CLEANED_BODY" == *"OneClient"* ]]; then
35+
LABELS="oneclient"
36+
elif [[ "$CLEANED_BODY" == *"OneLauncher"* ]]; then
37+
LABELS="onelauncher"
38+
fi
39+
40+
echo "LABELS=$LABELS" >> $GITHUB_ENV
41+
42+
- name: Add labels to issue
43+
run: |
44+
if [[ -n "${{ env.LABELS }}" ]]; then
45+
gh issue edit "${{ github.event.issue.number }}" --add-label "${{ env.LABELS }}"
46+
fi
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
GH_REPO: ${{ github.repository }}
50+

.github/workflows/labeler.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/labeler@v6
13+
with:
14+
sync-labels: true

0 commit comments

Comments
 (0)