-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yml
More file actions
352 lines (339 loc) · 12.5 KB
/
action.yml
File metadata and controls
352 lines (339 loc) · 12.5 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
name: 'GitHub Copilot CLI'
description: 'GitHub Copilot CLI wrapper'
branding:
icon: 'cpu'
color: 'purple'
inputs:
copilot-token:
description: '(Deprecated) The default github.token now supports copilot-requests permission — no PAT needed. Only provide this if you need to override with a specific token.'
required: false
default: ${{ github.token }}
prompt:
description: 'Prompt to send to GitHub Copilot'
required: true
mcp-config:
description: 'MCP configuration for GitHub Copilot [Link](https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/extend-coding-agent-with-mcp#writing-a-json-configuration-for-mcp-servers)'
required: false
copilot-config:
description: 'Configuration for GitHub Copilot'
required: false
default: |
{
"banner": "never",
"render_markdown": true,
"theme": "auto",
"trusted_folders": []
}
autopilot:
description: 'Enable autopilot continuation in prompt mode'
required: false
default: true
max-turns:
description: 'Maximum number of autopilot continuation turns (default: unlimited)'
required: false
no-ask-user:
description: 'Disable the ask_user tool so the agent works autonomously without asking questions'
required: false
default: true
silent:
description: 'Output only the agent response without usage statistics'
required: false
default: false
allow-all-tools:
description: 'Allow all tools without approval'
required: false
default: true
allowed-tools:
description: 'Comma-separated list of tools to allow (e.g., "shell(rm),shell(git push)")'
required: false
denied-tools:
description: 'Comma-separated list of tools to deny (e.g., "shell(rm),shell(git push)")'
required: false
allowed-urls:
description: 'Comma-separated list of URLs or domains to allow (e.g., "github.com,*.api.com")'
required: false
denied-urls:
description: 'Comma-separated list of URLs or domains to deny (e.g., "evil.com")'
required: false
copilot-version:
description: 'Version of Copilot CLI to install (e.g., "latest", "prerelease", "0.0.329")'
required: false
default: 'prerelease'
model:
description: 'Model to use (e.g., "claude-sonnet-4.5", "claude-sonnet-4", "gpt-5")'
required: false
additional-directories:
description: 'Comma-separated list of additional directories to trust for file access (e.g., "/tmp,/var/log")'
required: false
disable-mcp-servers:
description: 'Comma-separated list of MCP servers to disable (e.g., "github-mcp-server,custom-server")'
required: false
disable-builtin-mcps:
description: 'Disable all built-in MCP servers (github-mcp-server, playwright, fetch, time)'
required: false
default: false
enable-all-github-mcp-tools:
description: 'Enable all GitHub MCP tools'
required: false
default: false
add-github-mcp-tools:
description: 'Comma-separated list of specific GitHub MCP tools to enable (e.g., "create_issue,search_code")'
required: false
add-github-mcp-toolsets:
description: 'Comma-separated list of GitHub MCP toolsets to enable (e.g., "issues,pull_requests")'
required: false
resume-session:
description: 'Resume from a previous session ID (use "latest" for most recent)'
required: false
upload-artifact:
description: 'Upload artifact after running Copilot'
required: false
default: true
agent:
description: 'Specify a custom agent to use'
required: false
reasoning-effort:
description: 'Set the reasoning effort level (e.g., "low", "medium", "high", "xhigh")'
required: false
output-format:
description: 'Output format (e.g., "json" for JSONL output in prompt mode)'
required: false
experimental:
description: 'Enable experimental features'
required: false
default: false
share:
description: 'Share session to a markdown file after completion (provide a file path, or "true" for default)'
required: false
share-gist:
description: 'Share session to a secret GitHub gist after completion'
required: false
default: false
fail-on-error:
description: 'Fail the step if the Copilot CLI exits with a non-zero exit code'
required: false
default: false
log-level:
description: 'Set the log level (choices: "none", "error", "warning", "info", "debug", "all", "default")'
required: false
default: 'all'
options:
description: 'Additional options to pass to the Copilot CLI (e.g., "--no-custom-instructions --model gpt-5")'
required: false
default: '--screen-reader --no-color --stream off'
outputs:
logs-path:
description: 'Path to the copilot logs directory'
value: ${{ steps.copilot.outputs.logs_path }}
exit-code:
description: 'Exit code from the Copilot CLI command'
value: ${{ steps.copilot.outputs.exit_code }}
session-path:
description: 'Path to the shared session markdown file (if share was used)'
value: ${{ steps.copilot.outputs.session_path }}
runs:
using: 'composite'
steps:
- uses: actions/setup-copilot@v0
with:
version: ${{ inputs.copilot-version }}
- name: Run GitHub Copilot CLI
id: copilot
shell: bash
run: |
# Script
echo "::group::Copilot CLI Version"
echo "CLI Version: $(copilot --version)"
echo "::endgroup::"
if [ -n "$CONFIG" ]; then
echo "::group::Configure Copilot"
mkdir -p $HOME/.copilot
echo "$CONFIG" > $HOME/.copilot/config.json
cat $HOME/.copilot/config.json
echo "::endgroup::"
fi
if [ -n "$MCP_CONFIG" ]; then
echo "::group::Configure Copilot MCP"
cat $HOME/.copilot/mcp-config.json 2>/dev/null || echo "No existing MCP config found"
mkdir -p $HOME/.copilot
BASE_MCP_CONFIG='{
"mcpServers": { }
}'
MERGED_MCP_CONFIG=$(echo "$BASE_MCP_CONFIG" | jq --argjson user "$MCP_CONFIG" '.mcpServers += $user.mcpServers')
echo "$MERGED_MCP_CONFIG" > $HOME/.copilot/mcp-config.json
cat $HOME/.copilot/mcp-config.json
echo "::endgroup::"
fi
echo "::group::Copilot Options"
COPILOT_ARGS=""
COPILOT_ARGS+="--add-dir / "
if [ -n "$ADDITIONAL_DIRS" ]; then
IFS=',' read -ra DIRS <<< "$ADDITIONAL_DIRS"
for dir in "${DIRS[@]}"; do
COPILOT_ARGS+="--add-dir $dir "
done
fi
if [ -n "$DISABLE_MCP_SERVERS" ]; then
IFS=',' read -ra SERVERS <<< "$DISABLE_MCP_SERVERS"
for server in "${SERVERS[@]}"; do
COPILOT_ARGS+="--disable-mcp-server $server "
done
fi
if [ "$DISABLE_BUILTIN_MCPS" = "true" ]; then
COPILOT_ARGS+="--disable-builtin-mcps "
fi
if [ "$ENABLE_ALL_GITHUB_MCP_TOOLS" = "true" ]; then
COPILOT_ARGS+="--enable-all-github-mcp-tools "
fi
if [ -n "$ADD_GITHUB_MCP_TOOLS" ]; then
IFS=',' read -ra TOOLS <<< "$ADD_GITHUB_MCP_TOOLS"
for tool in "${TOOLS[@]}"; do
COPILOT_ARGS+="--add-github-mcp-tool $tool "
done
fi
if [ -n "$ADD_GITHUB_MCP_TOOLSETS" ]; then
IFS=',' read -ra TOOLSETS <<< "$ADD_GITHUB_MCP_TOOLSETS"
for toolset in "${TOOLSETS[@]}"; do
COPILOT_ARGS+="--add-github-mcp-toolset $toolset "
done
fi
if [ "$ALLOW_ALL_TOOLS" = "true" ]; then
COPILOT_ARGS+="--allow-all-tools "
fi
if [ -n "$ALLOWED_TOOLS" ]; then
IFS=',' read -ra TOOLS <<< "$ALLOWED_TOOLS"
for tool in "${TOOLS[@]}"; do
COPILOT_ARGS+="--allow-tool $tool "
done
fi
if [ -n "$DENIED_TOOLS" ]; then
IFS=',' read -ra TOOLS <<< "$DENIED_TOOLS"
for tool in "${TOOLS[@]}"; do
COPILOT_ARGS+="--deny-tool $tool "
done
fi
if [ -n "$ALLOWED_URLS" ]; then
IFS=',' read -ra URLS <<< "$ALLOWED_URLS"
for url in "${URLS[@]}"; do
COPILOT_ARGS+="--allow-url $url "
done
fi
if [ -n "$DENIED_URLS" ]; then
IFS=',' read -ra URLS <<< "$DENIED_URLS"
for url in "${URLS[@]}"; do
COPILOT_ARGS+="--deny-url $url "
done
fi
if [ -n "$MODEL" ]; then
COPILOT_ARGS+="--model $MODEL "
fi
if [ -n "$AGENT" ]; then
COPILOT_ARGS+="--agent $AGENT "
fi
if [ -n "$RESUME_SESSION" ]; then
if [ "$RESUME_SESSION" = "latest" ]; then
COPILOT_ARGS+="--continue "
else
COPILOT_ARGS+="--resume $RESUME_SESSION "
fi
fi
if [ -n "$LOG_LEVEL" ]; then
COPILOT_ARGS+="--log-level $LOG_LEVEL "
fi
if [ -n "$REASONING_EFFORT" ]; then
COPILOT_ARGS+="--reasoning-effort $REASONING_EFFORT "
fi
if [ -n "$OUTPUT_FORMAT" ]; then
COPILOT_ARGS+="--output-format $OUTPUT_FORMAT "
fi
if [ "$AUTOPILOT" = "true" ]; then
COPILOT_ARGS+="--autopilot "
fi
if [ -n "$MAX_TURNS" ]; then
COPILOT_ARGS+="--max-autopilot-continues $MAX_TURNS "
fi
if [ "$NO_ASK_USER" = "true" ]; then
COPILOT_ARGS+="--no-ask-user "
fi
if [ "$SILENT" = "true" ]; then
COPILOT_ARGS+="-s "
fi
if [ "$EXPERIMENTAL" = "true" ]; then
COPILOT_ARGS+="--experimental "
fi
if [ -n "$SHARE" ]; then
if [ "$SHARE" = "true" ]; then
COPILOT_ARGS+="--share "
else
COPILOT_ARGS+="--share=$SHARE "
fi
fi
if [ "$SHARE_GIST" = "true" ]; then
COPILOT_ARGS+="--share-gist "
fi
if [ -n "$EXTRA_ARGS" ]; then
COPILOT_ARGS+="$EXTRA_ARGS "
fi
COPILOT_ARGS+="--log-dir $HOME/.copilot/logs "
echo "$COPILOT_ARGS"
echo "::endgroup::"
echo "::group::Prompt"
echo "$PROMPT"
echo "::endgroup::"
echo "::group::Run Copilot CLI"
set +e
copilot -p "$PROMPT" $COPILOT_ARGS
EXIT_CODE=$?
echo "::endgroup::"
echo "logs_path=$HOME/.copilot/logs" >> $GITHUB_OUTPUT
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
# Capture session share path if it exists
SESSION_FILE=$(ls copilot-session-*.md 2>/dev/null | head -1)
if [ -n "$SESSION_FILE" ]; then
echo "session_path=$SESSION_FILE" >> $GITHUB_OUTPUT
fi
if [ "$FAIL_ON_ERROR" = "true" ] && [ "$EXIT_CODE" -ne 0 ]; then
echo "::error::Copilot CLI exited with code $EXIT_CODE"
exit $EXIT_CODE
fi
env:
GITHUB_TOKEN: ${{ inputs.copilot-token }}
GH_TOKEN: ${{ inputs.copilot-token }}
PROMPT: ${{ inputs.prompt }}
CONFIG: ${{ inputs.copilot-config }}
MCP_CONFIG: ${{ inputs.mcp-config }}
ALLOW_ALL_TOOLS: ${{ inputs.allow-all-tools }}
ALLOWED_TOOLS: ${{ inputs.allowed-tools }}
DENIED_TOOLS: ${{ inputs.denied-tools }}
MODEL: ${{ inputs.model }}
AGENT: ${{ inputs.agent }}
ADDITIONAL_DIRS: ${{ inputs.additional-directories }}
DISABLE_MCP_SERVERS: ${{ inputs.disable-mcp-servers }}
ENABLE_ALL_GITHUB_MCP_TOOLS: ${{ inputs.enable-all-github-mcp-tools }}
RESUME_SESSION: ${{ inputs.resume-session }}
LOG_LEVEL: ${{ inputs.log-level }}
REASONING_EFFORT: ${{ inputs.reasoning-effort }}
OUTPUT_FORMAT: ${{ inputs.output-format }}
AUTOPILOT: ${{ inputs.autopilot }}
MAX_TURNS: ${{ inputs.max-turns }}
NO_ASK_USER: ${{ inputs.no-ask-user }}
SILENT: ${{ inputs.silent }}
EXPERIMENTAL: ${{ inputs.experimental }}
SHARE: ${{ inputs.share }}
SHARE_GIST: ${{ inputs.share-gist }}
ALLOWED_URLS: ${{ inputs.allowed-urls }}
DENIED_URLS: ${{ inputs.denied-urls }}
DISABLE_BUILTIN_MCPS: ${{ inputs.disable-builtin-mcps }}
ADD_GITHUB_MCP_TOOLS: ${{ inputs.add-github-mcp-tools }}
ADD_GITHUB_MCP_TOOLSETS: ${{ inputs.add-github-mcp-toolsets }}
FAIL_ON_ERROR: ${{ inputs.fail-on-error }}
EXTRA_ARGS: ${{ inputs.options }}
- name: Upload Copilot Artifacts
uses: actions/upload-artifact@v4
if: ${{ always() && inputs.upload-artifact == 'true' }}
with:
name: copilot-logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
~/.copilot/logs
copilot-session-*.md
if-no-files-found: warn