bin/run-publisher.shStatus: Complete
Date: 2026-03-16
File: apps/blog/bin/run-publisher.sh
Created the entrypoint script that the K8s controller invokes to run the autonomous publisher pipeline. Handles branch lifecycle, auth setup, Claude invocation, git push, PR creation, and Discord notification.
CLAUDE_CODE_OAUTH_TOKEN (required); GITHUB_TOKEN is optional — skips push and PR if unsetpublisher-agent) if not already configuredagent/publisher-$(date +%s)ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL
(prevents auth conflict discovered in TASK-001)claude --mcp-config /tmp/mcp.json --agent publisher -p "$1" --output-format textgit push, gh pr create, Discord webhook notificationThe script runs outside Claude Code context so MCP isn't available.
A simple curl POST to DISCORD_WEBHOOK_URL is used. The env var is
optional -- if unset, notifications are skipped (the run doesn't fail
over it).
Claude Code output is captured via tee to a temp file. On failure,
tail -20 of that file is included in the Discord notification. This
gives enough context to debug without logging into the pod.
Because set -o pipefail is active, the pipe claude ... | tee would
exit with the first failing command's code. We use || true on the
pipeline and then check ${PIPESTATUS[0]} to get Claude's actual exit
code separately from tee's.
bash -n syntax check: passedchmod +x: doneagent/publisher-$(date +%s) from current HEADANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URLclaude --mcp-config /tmp/mcp.json --agent publisher -p "$1" --output-format textgit push, gh pr create