Skip to Content
LYNKORIADocs

Step 4: GitHub

Create the staging and production environments and give them the secrets and variables the Deploy and Infrastructure workflows pass to OpenTofu.

Goal: GitHub environments staging and production that hold everything the workflows need, with production behind a required reviewer.

4.1 Create the environments

Repository → Settings → Environments → New environment:

  • staging: allow the main branch.
  • production: add Required reviewers (one or more people) and allow only main.

Also protect main (Settings → Rules or Branches): pull requests and passing CI required.

4.2 Secrets (per environment)

Settings → Environments → (environment) → Add environment secret.

SecretValueRequired
DIGITALOCEAN_ACCESS_TOKENStep 2.1Yes
SPACES_ACCESS_KEY_IDStep 2.2Yes
SPACES_SECRET_ACCESS_KEYStep 2.2Yes
CLOUDFLARE_API_TOKENStep 2.5Yes
TOFU_STATE_PASSPHRASEThis environment's passphrase (2.4)Yes
TOFU_ZONE_STATE_PASSPHRASEThe zone passphrase (same value in both environments)Yes
PUSH_CREDENTIALS_JSONProduct push credentials; leave unset until a product enables pushNo
MONITORING_REMOTE_WRITE_USERNAMERemote-write user (step 10)No
MONITORING_REMOTE_WRITE_PASSWORDRemote-write passwordNo

The zone stack runs in the production environment, so production must hold TOFU_ZONE_STATE_PASSPHRASE too.

4.3 Variables (per environment)

Settings → Environments → (environment) → Add environment variable. List values are JSON.

VariableExampleRequired
TOFU_STATE_BUCKETlynkoria-tofu-state-x1y2Yes
DOCR_REGISTRYyour-registryYes
CLOUDFLARE_ACCOUNT_IDAccount ID from the dashboardYes
CLOUDFLARE_ZONE_IDZone ID of lynkoria.comYes
CF_ACCESS_TEAM_DOMAINyour-team.cloudflareaccess.comWith Access on
ACCESS_ALLOWED_EMAILS["ana@example.com","ben@example.com"]With Access on
ENABLE_ACCESSfalse only to run without Cloudflare Access (no MFA in front of the console; see manual deployment 1.6)No (default true)
OWNER_EMAILana@example.com (gets the console owner role)Yes
SSH_KEY_FINGERPRINTS["3b:16:…"]Yes
ADMIN_IPS["203.0.113.10/32"]Yes
ALERT_EMAILS["oncall@example.com"] (DigitalOcean team members)No
API_DNS_PROXIEDfalse only for the first deploy (step 6)No
MONITORING_REMOTE_WRITE_URLPrometheus remote-write URLNo

The workflows map these to OpenTofu variables (TF_VAR_*); the mapping is visible in .github/workflows/deploy.yml.

4.4 What the workflows do with them

WorkflowTriggerRuns
ci.ymlEvery push and pull requestTests, builds, tofu validate, mocked tofu test. No secrets
infra.ymlPull requests touching infra/opentofu/; manualtofu plan (staging on PRs); manual plan for any stack; apply for the zone stack
deploy.ymlCI green on main (staging); manual (either)Build and scan images → tofu apply → smoke test → Pages publish

Every run that touches state is serialized per stack with a concurrency group, so two applies never overlap.

Verify

Both environments list all required secrets and variables. A manual Actions → Infrastructure → Run workflow → stack: staging, action: plan reports that staging has not been deployed yet (that is expected before step 6) instead of a credentials error.

Next: Step 5: Zone stack.

On this page