-
Notifications
You must be signed in to change notification settings - Fork 4.2k
178 lines (162 loc) · 5.96 KB
/
continue-agents.yml
File metadata and controls
178 lines (162 loc) · 5.96 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Continue Agents
on:
workflow_call:
inputs:
agents-path:
description: 'Path to agents folder'
required: false
default: '.continue/agents'
type: string
secrets:
ANTHROPIC_API_KEY:
description: 'Anthropic API key for Claude'
required: true
permissions:
contents: write
checks: write
pull-requests: write
jobs:
discover:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.discover.outputs.matrix }}
has-agents: ${{ steps.discover.outputs.has_agents }}
steps:
- uses: actions/checkout@v6
- name: Discover agents
id: discover
run: |
AGENTS_DIR="${{ inputs.agents-path }}"
if [ -d "$AGENTS_DIR" ]; then
# Use -sc for compact single-line JSON (required for GitHub Actions output)
FILES=$(find "$AGENTS_DIR" -name "*.md" -type f 2>/dev/null | jq -R . | jq -sc .)
COUNT=$(echo "$FILES" | jq 'length')
HAS_AGENTS=$([[ $COUNT -gt 0 ]] && echo "true" || echo "false")
else
FILES="[]"
COUNT=0
HAS_AGENTS="false"
fi
echo "matrix=$FILES" >> $GITHUB_OUTPUT
echo "has_agents=$HAS_AGENTS" >> $GITHUB_OUTPUT
echo "Found $COUNT agent(s)"
run-agent:
needs: discover
if: needs.discover.outputs.has-agents == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
agent: ${{ fromJson(needs.discover.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install Continue CLI
run: npm i -g @continuedev/cli
- name: Extract agent name
id: agent-name
run: |
AGENT_FILE="${{ matrix.agent }}"
AGENT_NAME=$(basename "$AGENT_FILE" .md)
echo "name=$AGENT_NAME" >> $GITHUB_OUTPUT
- name: Create Check Run
id: check
uses: actions/github-script@v8
env:
AGENT_NAME: ${{ steps.agent-name.outputs.name }}
with:
script: |
const { data: check } = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: `Continue: ${process.env.AGENT_NAME}`,
head_sha: context.sha,
status: 'in_progress',
started_at: new Date().toISOString(),
});
core.setOutput('id', check.id);
- name: Run agent
id: run
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GH_TOKEN: ${{ github.token }}
run: |
AGENT_FILE="${{ matrix.agent }}"
# Run agent in non-interactive mode (-p flag)
if OUTPUT=$(cn -p --agent "$AGENT_FILE" 2>&1); then
echo "success=true" >> $GITHUB_OUTPUT
echo "output<<EOF" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "✅ Agent completed successfully"
echo ""
echo "--- Agent Output ---"
echo "$OUTPUT"
else
echo "success=false" >> $GITHUB_OUTPUT
echo "error<<EOF" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "❌ Agent failed"
echo ""
echo "--- Agent Output ---"
echo "$OUTPUT"
fi
- name: Write job summary
if: always()
env:
AGENT_OUTPUT: ${{ steps.run.outputs.output }}
AGENT_ERROR: ${{ steps.run.outputs.error }}
AGENT_SUCCESS: ${{ steps.run.outputs.success }}
AGENT_NAME: ${{ steps.agent-name.outputs.name }}
run: |
echo "## 🤖 Agent: $AGENT_NAME" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "$AGENT_SUCCESS" == "true" ]; then
echo "✅ **Status:** Completed successfully" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Output" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
printf '%s\n' "$AGENT_OUTPUT" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Status:** Failed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Error" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
printf '%s\n' "$AGENT_ERROR" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi
- name: Fail if agent failed
if: steps.run.outputs.success != 'true'
run: exit 1
- name: Update Check Run
if: always()
uses: actions/github-script@v8
env:
AGENT_OUTPUT: ${{ steps.run.outputs.output }}
AGENT_ERROR: ${{ steps.run.outputs.error }}
AGENT_SUCCESS: ${{ steps.run.outputs.success }}
CHECK_RUN_ID: ${{ steps.check.outputs.id }}
with:
script: |
const success = process.env.AGENT_SUCCESS === 'true';
const output = process.env.AGENT_OUTPUT || '';
const error = process.env.AGENT_ERROR || '';
await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: parseInt(process.env.CHECK_RUN_ID, 10),
status: 'completed',
conclusion: success ? 'success' : 'failure',
completed_at: new Date().toISOString(),
output: {
title: success ? 'Agent completed' : 'Agent failed',
summary: success
? `Agent completed successfully.\n\n<details><summary>Output</summary>\n\n\`\`\`\n${output.slice(0, 60000)}\n\`\`\`\n</details>`
: `Agent failed.\n\n\`\`\`\n${error.slice(0, 60000)}\n\`\`\``,
},
});