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
Owner

Adds image/image_digest/rollback/env_file/output_file inputs. Makes stack_name required (was buggy default). Adds structured JSON output the orchestrator can parse. Tested with ./test.sh: 8/8 pass with a mocked Portainer. See gitea-deploy-orchestrator for the consumer.

Adds image/image_digest/rollback/env_file/output_file inputs. Makes stack_name required (was buggy default). Adds structured JSON output the orchestrator can parse. Tested with ./test.sh: 8/8 pass with a mocked Portainer. See gitea-deploy-orchestrator for the consumer.
kaykayyali added 1 commit 2026-06-18 13:26:03 +00:00
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.
kaykayyali merged commit 99714ada82 into main 2026-06-27 16:43:37 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kaykayyali/portainer-deploy-action#1