27 lines
812 B
Plaintext
27 lines
812 B
Plaintext
|
|
#!/usr/bin/env nu
|
||
|
|
# notify.nu — emit a NATS result event after successful install.
|
||
|
|
# Reads JSON inputs from stdin (installed).
|
||
|
|
# Emits empty JSON object to stdout (no output capabilities).
|
||
|
|
|
||
|
|
def main []: nothing -> nothing {
|
||
|
|
let inputs = ($in | from json)
|
||
|
|
let installed = ($inputs | get "installed")
|
||
|
|
|
||
|
|
if (not ($installed.ok)) {
|
||
|
|
error make { msg: "installed.ok is false — not notifying" }
|
||
|
|
}
|
||
|
|
|
||
|
|
let run_id = ($env | get --ignore-errors PIPELINE_RUN_ID | default "unknown")
|
||
|
|
let payload = { run_id: $run_id, binary: $installed.binary_path, version: $installed.version }
|
||
|
|
|
||
|
|
let pub_result = (do {
|
||
|
|
^nats pub dev.crate.built ($payload | to json)
|
||
|
|
} | complete)
|
||
|
|
|
||
|
|
if ($pub_result.exit_code != 0) {
|
||
|
|
error make { msg: $"nats pub failed: ($pub_result.stderr)" }
|
||
|
|
}
|
||
|
|
|
||
|
|
{} | to json | print
|
||
|
|
}
|