-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathaction.yml
More file actions
283 lines (266 loc) · 10.4 KB
/
Copy pathaction.yml
File metadata and controls
283 lines (266 loc) · 10.4 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
name: "Agent Beacon CI Telemetry"
description: "Capture agent CI telemetry to Agent Beacon JSONL, artifacts, or customer-managed destinations."
author: "Asymptote Labs"
branding:
icon: "radio"
color: "purple"
inputs:
mode:
description: "How to run Beacon CI telemetry: 'exec' (default), 'start', or 'finish'."
required: false
default: "exec"
command:
description: >-
The Claude Code command to run, e.g. claude --print "Summarize this repo".
Executed via bash -c so the configured telemetry environment reaches it.
Required when mode is 'exec'.
required: false
default: ""
harnesses:
description: "Comma-separated agent harnesses to configure, e.g. claude,codex."
required: false
default: ""
version:
description: >-
Beacon CLI release tag to download (e.g. v0.0.39). Defaults to a version
pinned by this action. SIEM forwarding requires a release that includes
the ci exec --forward feature.
required: false
default: ""
binary-path:
description: >-
Path to an existing beacon binary. When set, the download and checksum
verification are skipped. Use for air-gapped or self-hosted runners. The
beacon-otelcol collector must sit beside it.
required: false
default: ""
min-events:
description: "Minimum Beacon events required for telemetry validation to pass."
required: false
default: "1"
require-telemetry:
description: >-
Fail the step when telemetry validation fails. Set to 'false' to downgrade
a telemetry-pipeline failure to a warning so it does not gate the build.
required: false
default: "true"
forward:
description: >-
Optional SIEM forwarder: 'splunk' or 'falcon'. Leave empty to disable.
The token must be supplied via the BEACON_CI_SPLUNK_HEC_TOKEN or
BEACON_CI_FALCON_HEC_TOKEN environment variable (set it at the job or
workflow level from a secret), never as an input.
required: false
default: ""
forward-endpoint:
description: "SIEM HEC endpoint URL for the selected --forward provider."
required: false
default: ""
upload:
description: >-
Optional post-run artifact upload destinations: 's3', 'gcs', or a
comma-separated list. Configure provider credentials at the job level
using the normal AWS or Google Cloud CI mechanisms.
required: false
default: ""
upload-artifact:
description: "Upload the runtime JSONL log as the universal workflow artifact."
required: false
default: "true"
artifact-name:
description: "Name for the uploaded telemetry artifact."
required: false
default: "beacon-runtime-log"
outputs:
log-path:
description: "Path to the Beacon runtime JSONL log."
value: ${{ steps.paths.outputs.log-path }}
state-path:
description: "Path to the Beacon CI session state file."
value: ${{ steps.paths.outputs.state-path }}
codex-home:
description: "Path to Beacon's generated Codex home directory."
value: ${{ steps.paths.outputs.codex-home }}
runs:
using: "composite"
steps:
- name: Resolve Beacon binary
id: resolve
shell: bash
env:
# A specific tag is pinned here rather than resolving "latest" so runs
# are reproducible and the downloaded archive can be checksum-verified.
DEFAULT_BEACON_VERSION: "v0.0.49"
ACTION_REF: ${{ github.action_ref }}
INPUT_VERSION: ${{ inputs.version }}
INPUT_BINARY_PATH: ${{ inputs.binary-path }}
run: |
set -euo pipefail
if [ -n "${INPUT_BINARY_PATH}" ]; then
if [ ! -x "${INPUT_BINARY_PATH}" ]; then
echo "::error::binary-path '${INPUT_BINARY_PATH}' is not an executable file"
exit 1
fi
echo "beacon-bin=${INPUT_BINARY_PATH}" >> "$GITHUB_OUTPUT"
echo "Using provided beacon binary: ${INPUT_BINARY_PATH}"
exit 0
fi
version="${INPUT_VERSION:-${ACTION_REF:-$DEFAULT_BEACON_VERSION}}"
if [ "${version#v}" = "${version}" ]; then
echo "::error::Beacon release version '${version}' is not a version tag. Set the version input or binary-path when using a branch/local action ref."
exit 1
fi
case "$(uname -s)" in
Linux) os="linux" ;;
Darwin) os="darwin" ;;
*) echo "::error::unsupported operating system $(uname -s)"; exit 1 ;;
esac
case "$(uname -m)" in
x86_64|amd64) arch="amd64" ;;
arm64|aarch64) arch="arm64" ;;
*) echo "::error::unsupported architecture $(uname -m)"; exit 1 ;;
esac
ver_no_v="${version#v}"
archive="beacon_${ver_no_v}_${os}_${arch}.tar.gz"
base="https://github.com/asymptote-labs/agent-beacon/releases/download/${version}"
workdir="$(mktemp -d)"
echo "Downloading ${archive} (${version})"
curl -fsSL "${base}/${archive}" -o "${workdir}/${archive}"
curl -fsSL "${base}/checksums.txt" -o "${workdir}/checksums.txt"
# Verify the archive against the release checksums before extracting.
expected="$(grep " ${archive}\$" "${workdir}/checksums.txt" | awk '{print $1}')"
if [ -z "${expected}" ]; then
echo "::error::no checksum entry for ${archive} in checksums.txt"
exit 1
fi
if command -v sha256sum >/dev/null 2>&1; then
actual="$(sha256sum "${workdir}/${archive}" | awk '{print $1}')"
else
actual="$(shasum -a 256 "${workdir}/${archive}" | awk '{print $1}')"
fi
if [ "${expected}" != "${actual}" ]; then
echo "::error::checksum mismatch for ${archive}: expected ${expected}, got ${actual}"
exit 1
fi
tar -xzf "${workdir}/${archive}" -C "${workdir}"
chmod +x "${workdir}/beacon" "${workdir}/beacon-otelcol" 2>/dev/null || true
echo "beacon-bin=${workdir}/beacon" >> "$GITHUB_OUTPUT"
echo "Verified and extracted beacon ${version} to ${workdir}"
- name: Resolve Beacon paths
id: paths
shell: bash
run: |
set -euo pipefail
log_dir="${BEACON_CI_BASE_DIR:-${RUNNER_TEMP:-$(mktemp -d)}/beacon}"
mkdir -p "${log_dir}"
echo "base-dir=${log_dir}" >> "$GITHUB_OUTPUT"
echo "log-path=${log_dir}/runtime.jsonl" >> "$GITHUB_OUTPUT"
echo "state-path=${log_dir}/session.json" >> "$GITHUB_OUTPUT"
echo "codex-home=${log_dir}/codex-home" >> "$GITHUB_OUTPUT"
- name: Run command with Beacon telemetry
id: exec
if: ${{ inputs.mode == 'exec' }}
shell: bash
env:
BEACON_BIN: ${{ steps.resolve.outputs.beacon-bin }}
INPUT_HARNESSES: ${{ inputs.harnesses }}
INPUT_COMMAND: ${{ inputs.command }}
INPUT_MIN_EVENTS: ${{ inputs.min-events }}
INPUT_REQUIRE_TELEMETRY: ${{ inputs.require-telemetry }}
INPUT_FORWARD: ${{ inputs.forward }}
INPUT_FORWARD_ENDPOINT: ${{ inputs.forward-endpoint }}
INPUT_UPLOAD: ${{ inputs.upload }}
LOG_PATH: ${{ steps.paths.outputs.log-path }}
run: |
set -euo pipefail
if [ -z "${INPUT_COMMAND}" ]; then
echo "::error::input 'command' is required when mode is 'exec'"
exit 1
fi
args=(ci exec
--log-path "${LOG_PATH}"
--min-events "${INPUT_MIN_EVENTS}"
"--require-telemetry=${INPUT_REQUIRE_TELEMETRY}"
)
if [ -n "${INPUT_HARNESSES}" ]; then
args+=(--harness "${INPUT_HARNESSES}")
fi
if [ -n "${INPUT_FORWARD}" ]; then
args+=(--forward "${INPUT_FORWARD}")
if [ -n "${INPUT_FORWARD_ENDPOINT}" ]; then
args+=(--forward-endpoint "${INPUT_FORWARD_ENDPOINT}")
fi
fi
if [ -n "${INPUT_UPLOAD}" ]; then
IFS=',' read -ra upload_values <<< "${INPUT_UPLOAD}"
for upload in "${upload_values[@]}"; do
upload="${upload//[[:space:]]/}"
if [ -n "${upload}" ]; then
args+=(--upload "${upload}")
fi
done
fi
# INPUT_COMMAND is passed through the environment (not interpolated into
# this script) so workflow inputs cannot inject shell commands.
"${BEACON_BIN}" "${args[@]}" -- bash -c "${INPUT_COMMAND}"
- name: Start Beacon telemetry session
id: start
if: ${{ inputs.mode == 'start' }}
shell: bash
env:
BEACON_BIN: ${{ steps.resolve.outputs.beacon-bin }}
INPUT_HARNESSES: ${{ inputs.harnesses }}
INPUT_FORWARD: ${{ inputs.forward }}
INPUT_FORWARD_ENDPOINT: ${{ inputs.forward-endpoint }}
LOG_PATH: ${{ steps.paths.outputs.log-path }}
STATE_PATH: ${{ steps.paths.outputs.state-path }}
run: |
set -euo pipefail
harnesses="${INPUT_HARNESSES:-claude,codex}"
args=(ci start
--log-path "${LOG_PATH}"
--state-path "${STATE_PATH}"
--github-env "${GITHUB_ENV}"
--harness "${harnesses}"
)
if [ -n "${INPUT_FORWARD}" ]; then
args+=(--forward "${INPUT_FORWARD}")
if [ -n "${INPUT_FORWARD_ENDPOINT}" ]; then
args+=(--forward-endpoint "${INPUT_FORWARD_ENDPOINT}")
fi
fi
"${BEACON_BIN}" "${args[@]}"
- name: Finish Beacon telemetry session
id: finish
if: ${{ always() && inputs.mode == 'finish' }}
shell: bash
env:
BEACON_BIN: ${{ steps.resolve.outputs.beacon-bin }}
INPUT_MIN_EVENTS: ${{ inputs.min-events }}
INPUT_REQUIRE_TELEMETRY: ${{ inputs.require-telemetry }}
INPUT_UPLOAD: ${{ inputs.upload }}
STATE_PATH: ${{ steps.paths.outputs.state-path }}
run: |
set -euo pipefail
args=(ci finish
--state-path "${STATE_PATH}"
--min-events "${INPUT_MIN_EVENTS}"
"--require-telemetry=${INPUT_REQUIRE_TELEMETRY}"
)
if [ -n "${INPUT_UPLOAD}" ]; then
IFS=',' read -ra upload_values <<< "${INPUT_UPLOAD}"
for upload in "${upload_values[@]}"; do
upload="${upload//[[:space:]]/}"
if [ -n "${upload}" ]; then
args+=(--upload "${upload}")
fi
done
fi
"${BEACON_BIN}" "${args[@]}"
- name: Upload Beacon telemetry
if: ${{ always() && inputs.upload-artifact == 'true' && inputs.mode != 'start' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: ${{ steps.paths.outputs.log-path }}
if-no-files-found: warn