How it runs
The collector is a scheduled GitHub Actions job, .github/workflows/collector.yml. It is not
serverless and not Vercel cron: env-sync needs the aws, gh and op binaries and
OP_SERVICE_ACCOUNT_TOKEN on its host, which a hosted runner provides and a function does not.
The dashboard (apps/web) is a separate Next.js app that only reads.
The pipeline
cron "0 */6 * * *" (or workflow_dispatch)
|
v
1. checkout env-sync-viewer
2. fetch fleet manifests ---------- scripts/fetch-manifests.sh -> manifests/<repo>/secrets.manifest.yml
3. checkout + build env-sync ------ pinned commit SHA, symlinked onto PATH as `env-sync`
4. build the collector ------------ turbo run build --filter=@env-sync-viewer/collector...
5. join the tailnet --------------- ephemeral tagged node (1Password Connect reads)
6. pre-flight --------------------- scripts/preflight.ts -> $RUNNER_TEMP/inventory.filtered.json
7. collect ------------------------ node dist/main.js <filtered inventory>
| a. CI guards (exit 2)
| b. probes P-a, P-b (exit 3)
| c. one env-sync diff per selector -> one transaction per invocation
v
8. fail on pre-flight drops ------- red job if any service was dropped
Postgres sits at the end of step 7, and the dashboard reads from it:
collector (INSERT-only role) --> env_sync.collector_runs <-- viewer (SELECT-only role)
env_sync.drift_snapshots apps/web: auth + allowlist,
env_sync.drift_snapshot_keys no fingerprints to the browser
Step by step
Schedule. cron: "0 */6 * * *", every six hours, well inside the dashboard's 26-hour stale
threshold even if one run fails. concurrency: collector with cancel-in-progress: false means
runs queue rather than overlap. timeout-minutes: 90. Each env-sync invocation is capped at
10 minutes.
Fetch manifests. scripts/fetch-manifests.sh makes one Contents API call per repo
(gh api, GH_TOKEN) and writes manifests/<repo>/secrets.manifest.yml. A repo that fails gets
::warning::manifest fetch failed: <repo> and no file. It never gets an empty one, and the run
continues.
Build env-sync. env-sync is checked out at a pinned commit SHA and built on the runner.
Bumping that ref is a deliberate, reviewed change. Nothing upstream can change the job silently.
Tailnet. The job joins a tailnet as an ephemeral node so env-sync can read secrets through a
1Password Connect server instead of the rate-limited service account. The collector echoes
env-sync's reads: connect=N sa=M fallback=K line per invocation. Healthy is sa=0 fallback=0.
Pre-flight. Before any credential-bearing call, every (repo, service) in the inventory is
checked against the committed inventory.allow.json. Passing services become one entry each in
the filtered inventory, with a platforms scope. Failing ones are dropped with an ::error::
line. The step exits 0 so the rest is still collected. See
Collector reference.
Collect. main.js runs, in order:
- CI guards. With
CIset, it exits2if no inventory path was given, or if any entry lacks the pre-flight'splatformsscope. Nothing touches the database. - Probes. Two credential-free checks that the
env-synconPATHreally enforcesENV_SYNC_ALLOWED_PLATFORMS. P-a: an unknown platform*must be rejected. P-b: a CapRover target with an empty scope must be refused before any credential read. P-b runs only if P-a passes. A failure printsexpected/actual, exits3, and writes no row, so the dashboard keeps its last good data. - Collection. One
env-sync diff (--service <name> | --all) --env <env> --format jsonper selector. Each child gets an explicit environment, a fresh emptyHOME, and its ownENV_SYNC_ALLOWED_PLATFORMS. Each invocation writes onecollector_runsrow and its snapshot rows in one transaction.
Red on drops. The last step runs even if collection failed. If the pre-flight dropped anything, it prints the dropped names and fails the job.
Exit codes
| Code | Where | Meaning |
|---|---|---|
0 | main.js | every invocation was success or partial |
1 | main.js | at least one invocation was failed (its row is written) |
2 | main.js, CI | no inventory path, or an entry without a platforms scope; nothing ran |
3 | main.js | a probe failed: env-sync does not provably enforce the guard; nothing ran |
0 | preflight.ts | ran, even if it dropped services |
≠0 | preflight.ts | the inventory or allowlist file could not be read or parsed |
partial does not fail the job. Drift and per-target errors inside a trustworthy document are
data, and they show up on the dashboard.
What "healthy" looks like
- The job is green every six hours.
- The log shows
probe: ENV_SYNC_ALLOWED_PLATFORMS enforcement verified (P-a, P-b), then onesuccessorpartialline per selector. - Each invocation logs
env: base=[...] scoped=[...], the variable names it passed (never values), andreads: connect=N sa=0 fallback=0. - On the dashboard, no target is stale.
When the job goes red, the dashboard does not lie about it. A dead collector turns every target
stale within STALE_AFTER_HOURS. There is no active alerting yet. See
Architecture → known gaps.
Next: Setup (GitHub Actions).