refactor: orchestrator-leaf mode (image pin, rollback, structured output) #1

Merged
kaykayyali merged 1 commits from refactor/orchestrator-leaf into main 2026-06-27 16:43:37 +00:00

1 Commits

Author SHA1 Message Date
b7bdd065fa refactor: orchestrator-leaf mode
Extends the action to be a clean deploy leaf called by the gitea-deploy-orchestrator.
Backward-compatible with the existing direct-call pattern.

New inputs:
- env_file         .env file (merged with env_vars, env_vars wins)
- image            pin to specific image:tag (rewrites compose)
- image_digest     pin to specific sha256:... ref
- rollback         re-deploys the previous image digest from container labels
- previous_image_count  how many previous images to track
- force_pull       always pullImage:true (default true)
- prune            prune stopped containers on update (default true)
- output_file      write JSON result the orchestrator can parse
- fail_on_healthcheck  false = warn instead of fail

Bug fixes from the original:
- stack_name is now REQUIRED. The old default (derive from repo name) was broken
  on Gitea because path-style names (owner/repo) produce invalid Portainer stack
  names. Forces explicit config.
- Image/image_digest/rollback now have mutual exclusion checks that fail fast.
- env vars are now merged from env_file AND env_vars (env_vars wins), not
  replaced.

New infrastructure:
- Structured JSON output (status, action, stack_id, image, duration, error)
  lets the orchestrator parse deploy outcomes without scraping logs.
- Container-label-based rollback: orchestrator writes
  gitea-deploy-orchestrator.image-digest on every deploy, rollback reads it.

Pitfall fixes:
- Documented jq requirement (default ubuntu-latest has it, alpine does not).
- Documented stack_name as required (was: silently buggy).
- Documented rollback label dependency.

Tested with ./test.sh: 8/8 cases pass with a mocked Portainer.

See gitea-deploy-orchestrator for the consumer.
2026-06-18 07:20:44 +00:00