-
-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (117 loc) · 4.17 KB
/
Copy pathtask-execute.yml
File metadata and controls
132 lines (117 loc) · 4.17 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Agent Task Execution
on:
issues:
types: [labeled]
# Each issue gets its own concurrency group — new labels on the SAME issue
# cancel the previous run, but different issues run in parallel
concurrency:
group: agent-issue-${{ github.event.issue.number }}
cancel-in-progress: false
jobs:
route:
if: >-
startsWith(github.event.label.name, 'agent:') &&
github.event.label.name != 'agent:seo-vi' &&
github.event.label.name != 'agent:seo-cw3' &&
github.event.label.name != 'agent:biz-dev'
runs-on: ubuntu-latest
outputs:
runner: ${{ steps.pick.outputs.runner }}
steps:
- name: Pick runner by label
id: pick
env:
LABEL: ${{ github.event.label.name }}
run: |
case "$LABEL" in
*)
echo "runner=builder" >> $GITHUB_OUTPUT
;;
esac
execute:
needs: route
runs-on: [self-hosted, "${{ needs.route.outputs.runner }}"]
steps:
- uses: actions/checkout@v4
with:
ref: dev
fetch-depth: 0
clean: false
- name: Create branch
id: branch
run: |
BRANCH="agent/issue-${{ github.event.issue.number }}"
if git show-ref --verify --quiet "refs/heads/$BRANCH"; then
git branch -D "$BRANCH"
fi
git checkout -b "$BRANCH"
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
- name: Install dependencies and generate Prisma
timeout-minutes: 30
run: |
rm -rf .next
if [ -f node_modules/.yarn-integrity ]; then
echo "node_modules cached, skipping install"
else
yarn install --frozen-lockfile || yarn install
fi
npx prisma generate 2>/dev/null || true
npx prisma generate --schema=prisma/events/schema.prisma 2>/dev/null || true
npx playwright install chromium 2>/dev/null || true
printf "DATABASE_URL=%s\nEVENTS_DATABASE_URL=%s\n" "$DATABASE_URL" "$EVENTS_DATABASE_URL" > .env
- name: Determine role and execute
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_NAME: task-execute
GITHUB_RUN_ID: ${{ github.run_id }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
LABELS=$(gh issue view $ISSUE_NUMBER --json labels -q '.labels[].name')
BODY=$(gh issue view $ISSUE_NUMBER --json body -q '.body')
PROMPT_FILE=".claude/agents/fullstack.md"
ROLE="fullstack"
for R in seo-vi seo-cw3 biz-dev fullstack devops; do
if echo "$LABELS" | grep -q "agent:$R"; then
PROMPT_FILE=".claude/agents/${R}.md"
ROLE="$R"
break
fi
done
SYSTEM=$(cat "$PROMPT_FILE")
./agents-tools/run-agent.sh \
--agent "$ROLE" --role "${{ needs.route.outputs.runner }}" --trigger issue \
--issue "$ISSUE_NUMBER" \
--prompt-file "$PROMPT_FILE" \
-- "${SYSTEM}
TASK: ${ISSUE_TITLE}
ISSUE: #${ISSUE_NUMBER}
DETAILS: ${BODY}"
if [ $? -ne 0 ]; then
echo "Agent failed. See monitoring.db for details."
exit 1
fi
- name: Create PR
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
BRANCH="${{ steps.branch.outputs.branch }}"
if [ "$(git log origin/updates/dev-update..$BRANCH --oneline | wc -l)" -eq 0 ]; then
echo "No commits to push"
exit 1
fi
git push origin "$BRANCH"
# Use agent-generated PR body if available, otherwise fallback
if [ -f .agent-pr-body.md ]; then
PR_BODY=$(cat .agent-pr-body.md)
else
PR_BODY="Closes #${ISSUE_NUMBER}
Auto-generated by AI Agent."
fi
gh pr create \
--title "feat: ${ISSUE_TITLE}" \
--body "$PR_BODY" \
--base updates/dev-update \
--head "$BRANCH"