Skip to main content

Setup (GitHub Actions)

These are the setup instructions for the scheduled collector. The workflow itself is committed (.github/workflows/collector.yml). What you configure is the GitHub environment it runs in, the secrets inside it, and the database it writes to.

1. Prepare the database​

Run the schema and roles once with an admin connection, then create the collector's login role. See Getting started → step 1.

DATABASE_URL=<admin connection> pnpm db:deploy
CREATE ROLE env_sync_collector LOGIN PASSWORD '<secret>' IN ROLE collector; -- INSERT-only

Through Supabase's shared pooler, the username must be <role>.<project-ref> (env_sync_collector.<project-ref>). Without the suffix the pooler rejects the connection with (ENOIDENTIFIER) no tenant identifier provided.

2. Create the collector environment​

In Settings → Environments, create an environment named collector. The job declares environment: collector, so its secrets exist only for that job.

  • Deployment branches: main only. Secrets are then reachable only from code that merged.
  • Branch protection on main, requiring pull requests and code-owner review. .github/CODEOWNERS covers the workflow, the collector's scripts/, src/, test/, inventory.json, inventory.allow.json, and turbo.json.
  • No required reviewers on the environment. That would make every scheduled run wait for a click, and the dashboard would go stale. The thing worth reviewing is a change to what the cron runs, and branch protection already covers that.

Run it on GitHub-hosted ubuntu-latest (what the workflow uses). Never use a shared self-hosted runner: this job holds credentials that every other job on that runner could reach.

3. Add the secrets​

Set each one as an environment secret, for example gh secret set DATABASE_URL --env collector.

SecretUsed byWhat it is for
DATABASE_URLcollect stepthe collector login role from step 1. Never reaches env-sync
OP_SERVICE_ACCOUNT_TOKENevery env-sync child1Password service account. Reads plaintext in its vaults, so scope it tightly
ENV_SYNC_CONNECT_HOST, _TOKEN, _VAULTSevery env-sync child1Password Connect server for reads (the service account becomes the fallback)
TS_OAUTH_CLIENT_ID, TS_OAUTH_SECRETtailnet stepjoins the tailnet as an ephemeral, tagged node to reach Connect
ENV_SYNC_READ_TOKENenv-sync checkoutread access to the env-sync source, which is built on the runner
FLEET_MANIFESTS_READ_TOKENfetch-manifests stepGH_TOKEN for the Contents API: read access to each repo's secrets.manifest.yml
CAPROVER_ADMIN_PASSWORDCapRover children onlyCapRover reads. Only children scoped to caprover receive it

There are no repository variables to set. CAPROVER_ALLOWED_DOMAINS is deliberately a literal in collector.yml, not a variable: changing it needs a code-owner-reviewed PR, while a variable could be edited by any admin without review. env-sync refuses to send the CapRover password to any captainDomain outside that list, and refuses outright when it is unset.

Do not set ENV_SYNC_ALLOWED_PLATFORMS anywhere. The collector injects it per child from the pre-flight scope, and a test asserts it is absent from the workflow and from turbo.json.

The committed workflow also has one sparse-checkout step for a single repo's manifest, with its own read token. If you fork, you can drop it and rely on the Contents API fetch.

4. Add your first repo​

Say the repo is acme/orders, with services api and worker deployed to prod on CapRover.

  1. Fetch it. Add orders to the repo list in apps/collector/scripts/fetch-manifests.sh. The workflow calls it with no arguments, so it uses that list.

  2. Inventory it in apps/collector/inventory.json:

    [{ "manifestDir": "../../manifests/orders", "env": "prod", "services": ["api", "worker"] }]
  3. Allow it, one record per service, in apps/collector/inventory.allow.json. Every field must match the manifest exactly:

    {
    "repo": "orders",
    "service": "api",
    "platforms": ["caprover"],
    "captainDomain": "captain.example.com",
    "source": "app-secrets/orders/api",
    "appName": "orders-api"
    }
  4. Pin a fixture: copy the manifest to apps/collector/test/fixtures/manifests/orders/.

  5. Trust the domain: the captainDomain must be in the CAPROVER_ALLOWED_DOMAINS literal.

  6. Check it locally, then open a PR:

    pnpm --filter @env-sync-viewer/collector exec tsx scripts/preflight.ts
  7. After merge, run the workflow by hand (Actions → collector → Run workflow) and look for one success or partial line per service.

5. Point the dashboard at it​

Deploy apps/web with a viewer login role (IN ROLE viewer, SELECT-only), NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY, and VIEWER_ALLOWLIST. Turn email confirmation on in the Supabase project: the allowlist relies on it. Details are in Getting started → step 3.

Only CapRover, on purpose​

CapRover is the only platform with a credential rule today. Adding a second one (Vercel, Render, GitHub, SSM) has hard preconditions: one workflow job per platform, env-sync refusing adapters outside its scope (met by 0.5.0), and an identity check that pins each target to its reviewed record. The full credential-scoping rules and the step-by-step for a new platform are in apps/collector/README.md under "Credential scoping" and "Adding a platform".