-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (92 loc) · 3.94 KB
/
bot-validate-request.yml
File metadata and controls
107 lines (92 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: "Bot: Validate Plot Request"
run-name: "Validate: ${{ github.event.issue.title || 'Manual trigger' }}"
on:
workflow_dispatch:
inputs:
issue_number:
description: 'Issue number to validate'
required: true
type: string
issues:
types: [labeled]
concurrency:
group: validate-plot-request-${{ github.event.issue.number || github.run_id }}
cancel-in-progress: false
jobs:
validate-and-assign-id:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
id-token: write
steps:
- name: Check conditions
id: check
run: |
echo "=== Debug Info ==="
echo "Event: ${{ github.event_name }}"
echo "Action: ${{ github.event.action }}"
echo "Issue Number: ${{ github.event.issue.number }}"
echo "Issue Title: ${{ github.event.issue.title }}"
echo "Labels: ${{ join(github.event.issue.labels.*.name, ', ') }}"
echo "Label added (if labeled event): ${{ github.event.label.name }}"
echo "=================="
# Check 1: Must have plot-request label
HAS_LABEL="${{ contains(github.event.issue.labels.*.name, 'plot-request') }}"
if [[ "$HAS_LABEL" != "true" ]]; then
echo "::notice::Skipping: Issue does not have 'plot-request' label"
echo "should_run=false" >> $GITHUB_OUTPUT
exit 0
fi
# Check 2: Must not already have spec ID in title (indicated by [...])
TITLE="${{ github.event.issue.title }}"
if [[ "$TITLE" == *"["* ]]; then
echo "::notice::Skipping: Issue title already contains spec ID"
echo "should_run=false" >> $GITHUB_OUTPUT
exit 0
fi
# Check 3: For labeled events, only trigger when plot-request label is added
EVENT_ACTION="${{ github.event.action }}"
LABEL_NAME="${{ github.event.label.name }}"
if [[ "$EVENT_ACTION" == "labeled" && "$LABEL_NAME" != "plot-request" ]]; then
echo "::notice::Skipping: Labeled event but not plot-request label"
echo "should_run=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "::notice::All conditions met - proceeding with validation"
echo "should_run=true" >> $GITHUB_OUTPUT
- name: Checkout repository
if: steps.check.outputs.should_run == 'true'
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: React with eyes emoji
if: steps.check.outputs.should_run == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/reactions \
-f content=eyes
- name: Run Claude Code to validate and assign spec ID
if: steps.check.outputs.should_run == 'true'
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
claude_args: "--model opus"
prompt: |
## Task: Validate Plot Request and Assign Spec ID
Read the rules from `prompts/spec-id-generator.md` and follow them.
### Issue Details
- **Title:** ${{ github.event.issue.title }}
- **Number:** #${{ github.event.issue.number }}
- **Body:**
```
${{ github.event.issue.body }}
```
### Process
1. Read `prompts/spec-id-generator.md` for full instructions
2. List all existing specs in `specs/` directory
3. Analyze the request and check for duplicates
4. Post comment using `gh issue comment ${{ github.event.issue.number }} --body "..."`
5. If NEW: Update title with `gh issue edit ${{ github.event.issue.number }} --title "..."`
Workflow URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}