Skip to content

Commit 069c1fd

Browse files
maxprilutskiyclaude
andcommitted
feat: fix claude issue autolabeler to actually apply labels
- Enable Claude Code to use gh CLI directly via Bash tool - Add manual trigger support for processing existing issues - Create separate workflow to bulk-process all unlabeled issues - Set GITHUB_TOKEN env for proper gh authentication - Remove confirmation prompts with allowed_tools restriction 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8061753 commit 069c1fd

2 files changed

Lines changed: 74 additions & 3 deletions

File tree

.github/workflows/claude-issue-autolabel.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: Claude Issue Autolabeling
33
on:
44
issues:
55
types: [opened]
6+
workflow_dispatch:
7+
inputs:
8+
issue_number:
9+
description: 'Issue number to label'
10+
required: false
11+
type: string
612

713
jobs:
814
autolabel:
@@ -23,6 +29,22 @@ jobs:
2329
env:
2430
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2531

32+
- name: Get Target Issue
33+
id: target_issue
34+
run: |
35+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.issue_number }}" ]]; then
36+
echo "issue_number=${{ github.event.inputs.issue_number }}" >> $GITHUB_OUTPUT
37+
issue_data=$(gh issue view ${{ github.event.inputs.issue_number }} --json title,body)
38+
echo "issue_title=$(echo "$issue_data" | jq -r '.title')" >> $GITHUB_OUTPUT
39+
echo "issue_body=$(echo "$issue_data" | jq -r '.body')" >> $GITHUB_OUTPUT
40+
else
41+
echo "issue_number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
42+
echo "issue_title=${{ github.event.issue.title }}" >> $GITHUB_OUTPUT
43+
echo "issue_body=${{ github.event.issue.body }}" >> $GITHUB_OUTPUT
44+
fi
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
2648
- name: Autolabel Issue
2749
id: claude_analysis
2850
uses: anthropics/claude-code-action@beta
@@ -37,7 +59,7 @@ jobs:
3759
3860
Tasks:
3961
1. Analyze the issue content
40-
2. Use `gh issue edit ${{ github.event.issue.number }} --add-label "label-name"` to apply each relevant label
62+
2. Use `gh issue edit ${{ steps.target_issue.outputs.issue_number }} --add-label "label-name"` to apply each relevant label
4163
3. Add a comment explaining your labeling decisions
4264
4365
Requirements:
@@ -47,8 +69,8 @@ jobs:
4769
- Use the Bash tool to run gh commands WITHOUT asking for confirmation
4870
- The GITHUB_TOKEN is already set in the environment for gh authentication
4971
50-
Issue Title: ${{ github.event.issue.title }}
51-
Issue Body: ${{ github.event.issue.body }}
72+
Issue Title: ${{ steps.target_issue.outputs.issue_title }}
73+
Issue Body: ${{ steps.target_issue.outputs.issue_body }}
5274
env:
5375
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5476

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Label All Unlabeled Issues
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
find-and-label:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
issues: write
11+
contents: read
12+
actions: write
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Find and Label Unlabeled Issues
19+
run: |
20+
echo "Finding all unlabeled issues..."
21+
22+
# Get all unlabeled issues
23+
unlabeled_issues=$(gh issue list --limit 1000 --json number,labels --jq '.[] | select(.labels | length == 0) | .number')
24+
25+
if [[ -z "$unlabeled_issues" ]]; then
26+
echo "No unlabeled issues found"
27+
exit 0
28+
fi
29+
30+
echo "Found unlabeled issues:"
31+
echo "$unlabeled_issues"
32+
echo ""
33+
34+
# Process each issue by triggering the labeling workflow
35+
for issue_number in $unlabeled_issues; do
36+
echo "Triggering labeling workflow for issue #$issue_number..."
37+
38+
gh workflow run claude-issue-autolabel.yml \
39+
--ref ${{ github.ref }} \
40+
-f issue_number="$issue_number"
41+
42+
# Wait a bit to avoid overwhelming the system
43+
sleep 10
44+
done
45+
46+
echo "Triggered labeling workflows for all unlabeled issues"
47+
echo "Check workflow runs: gh run list --workflow=claude-issue-autolabel.yml"
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)