CI & Automation

Run Environment Sync unattended with tokens from environment variables, machine-readable JSON reports on stdout, and explicit flags in place of prompts.

Every sync command can run unattended. The contract in CI is deliberately strict: no prompts, no guessing, and nothing destructive without an explicit flag.

No prompts

Where the interactive CLI would ask a question, a non-interactive run refuses instead:

  • An ambiguous record match (two target records that could both be the committed one) fails the command rather than picking a candidate. Resolve it once with an interactive push; the answer lands in the committed identity map and CI runs cleanly after that.
  • Deletions happen only with --dangerously-allow-delete. A mirror push without it refuses before changing anything on the target.
  • --yes confirms an ordinary, non-destructive apply. It never authorizes a deletion.

Credentials

Pass tokens through environment variables named DIRECTUS_<PROFILE>_TOKEN:

DIRECTUS_PRODUCTION_TOKEN=$PROD_TOKEN d6s sync push --to production --yes

The credential store saved on a developer machine is never read in CI; tokens come from the environment only.

JSON reports

Add --json and stdout carries exactly one machine-readable report per command; pull, diff, and push each emit their own. Warnings (stripped secret fields, version drift, flow headers exported verbatim) still go to stderr, so your logs keep them while stdout stays parseable.

A diff whose records are ambiguous reports them as unresolved and counts them into its changes. A non-interactive push refuses that state, so an unresolved diff is a real difference for your pipeline to surface, not noise.

A typical pipeline

# On a schedule: refresh the committed snapshot from the source instance.
# Commit the result; a clean git status means nothing changed.
DIRECTUS_STAGING_TOKEN=$STAGING_TOKEN d6s sync pull --from staging --json

# In pull request checks: preview what merging would apply to the target.
DIRECTUS_PRODUCTION_TOKEN=$PROD_TOKEN d6s sync diff --to production --json

# On merge: apply.
DIRECTUS_PRODUCTION_TOKEN=$PROD_TOKEN d6s sync push --to production --yes --json

Exit behavior

Commands exit non-zero on any refusal or failure (an ambiguous match, a missing deletion flag, a version mismatch, a failed import), so a pipeline step fails visibly instead of continuing past a partial sync.

The push modes and deletion gates these flags control are covered in Diffing & Pushing.

Get once-a-month release notes & real‑world code tips...no fluff. 🐰