website-htmx-rustelo-code/site/scripts/nats/on-content-published.nu

24 lines
873 B
Text
Raw Permalink Normal View History

2026-07-10 03:44:13 +01:00
#!/usr/bin/env nu
# Triggered by pipeline: content-published
# Subject: ${NATS_NAMESPACE}.content.published
#
# Expected payload: { content_type: string, language: string, id: string }
#
# Env vars set by the executor:
# PIPELINE_EVENT — actual NATS subject
# PIPELINE_PAYLOAD — raw JSON body
let event = $env.PIPELINE_EVENT
let payload = $env.PIPELINE_PAYLOAD | from json
let content_type = $payload | get --optional content_type | default "unknown"
let language = $payload | get --optional language | default "unknown"
let id = $payload | get --optional id | default "unknown"
print $"[on-content-published] event=($event) type=($content_type) lang=($language) id=($id)"
# Add post-publish automation here, e.g.:
# - invalidate a CDN edge cache
# - trigger a search index update
# - send a webhook to an external service