Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
81 lines (77 loc) · 3.55 KB
/
Copy pathaction.yml
File metadata and controls
81 lines (77 loc) · 3.55 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
name: Murmur Kill
description: >-
Cancel a murmur agent (and its subtree). A composite action that runs the
published murmur CLI image (docker run … kill --json), authenticated with a
service-profile API key (mur_…). Idempotent teardown:
with tolerate-missing=true, killing an agent that is already gone (or was never
spawned) is treated as success, so it is safe to call on a lifecycle event
(e.g. PR closed) regardless of whether the agent still exists.
inputs:
api-key:
description: A mur_-prefixed service-profile API key. Pass via a secret, never inline.
required: true
api-address:
description: >-
murmur-api gRPC address as host:port (e.g. api.murmur.dev:9090), set on
MURMUR_API_ADDRESS. Leave empty to use the CLI's built-in production
default (api.murmur.dev:9090, TLS on).
required: false
default: ""
workspace:
description: Murmur workspace the agent runs in.
required: true
slug:
description: Slug of the agent to kill.
required: true
tolerate-missing:
description: >-
When "true" (default), a kill of an agent that does not exist (already torn
down, or never spawned) is reported as success — teardown is idempotent.
Real transport/auth errors still fail the step. Set "false" to fail on any
kill error.
required: false
default: "true"
runs:
# Composite (see actions/spawn/action.yml): runs the published murmur-cli image.
# The CLI knows nothing about GitHub Actions; the teardown glue lives here.
using: composite
steps:
- id: run
shell: bash
env:
MURMUR_API_KEY: ${{ inputs.api-key }}
MURMUR_API_ADDRESS: ${{ inputs.api-address }}
MURMUR_IMAGE: ghcr.io/prassoai/murmur-cli:v319.2@sha256:c4df4033475a70a0186188d4606c0c2ae820e7a8ea6ae002f992ab25b1a08c33
IN_WORKSPACE: ${{ inputs.workspace }}
IN_SLUG: ${{ inputs.slug }}
IN_TOLERATE_MISSING: ${{ inputs.tolerate-missing }}
run: |
set -euo pipefail
command -v docker >/dev/null || { echo "::error::docker is required to run this action" >&2; exit 1; }
# slug_log = slug with CR/LF stripped, for safe use in log lines — an
# untrusted slug containing "\n::error::…" could otherwise forge a
# workflow command. The raw $IN_SLUG still goes to the CLI.
slug_log=${IN_SLUG//[$'\n\r']/}
# A kill of an agent with no catalog record fails authz with NotFound (it
# was never spawned, or is already fully torn down). With tolerate-missing,
# absorb only that into a no-op success so teardown is idempotent; any
# other error (auth, transport) fails the step. mktemp gives a per-job
# error file so concurrent jobs on a shared runner can't clobber it.
err=$(mktemp)
if docker run --rm \
-e MURMUR_API_KEY -e MURMUR_API_ADDRESS \
"$MURMUR_IMAGE" kill --json "--workspace=$IN_WORKSPACE" -- "$IN_SLUG" \
>/dev/null 2>"$err"; then
echo "killed $slug_log" >&2
else
# Match the agent-not-found message specifically ("agent \"…\" not
# found"), NOT a bare "not found" — a tooling failure like "docker:
# command not found" must NOT be mistaken for an already-gone agent and
# silently skip a real teardown.
if [ "$IN_TOLERATE_MISSING" = "true" ] && grep -qiE 'agent .* not found' "$err"; then
echo "::notice::agent '$slug_log' not found — nothing to kill (idempotent teardown)." >&2
else
cat "$err" >&2
exit 1
fi
fi