Implement layered environment configuration system#254
Conversation
- Add layered .env file structure (.env, .env.development, .env.production) - Environment automatically selected based on git branch via .envrc - Base config in .env (no secrets) - Development config with test Turnstile keys - Production config with placeholders - All secrets moved to .env.local (not committed) - Update wrangler.toml with environment-specific configurations - Add comprehensive documentation in .env.README.md - Update .gitignore to allow base config files while keeping secrets ignored Loading order: .env → .env.$ENV → .env.local Branch mapping: dev/develop → development, main/master → production Co-Authored-By: Warp <agent@warp.dev>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
adblock-compiler | 36bd709 | Feb 03 2026, 09:16 PM |
- Create reusable composite action .github/actions/setup-env - Automatically detects environment from branch name (same logic as .envrc) - Loads .env and .env.$ENV files into workflow environment - Update CI workflow to use environment loading action - Add comprehensive documentation in .github/ENV_SETUP.md - Include GitHub Actions quickstart in .env.README.md The setup-env action provides: - Branch to environment mapping (main/master → production, dev/develop → development) - Automatic loading of layered .env files - Environment output for conditional workflow logic - Verification step to confirm variables loaded Co-Authored-By: Warp <agent@warp.dev>
- Remove .envrc from .gitignore - .envrc contains the environment loading logic needed for local development - No secrets in .envrc - all secrets remain in .env.local (still ignored) Co-Authored-By: Warp <agent@warp.dev>
The root .envrc now handles all environment loading with proper layered configuration. The worker/.envrc is no longer needed and contained outdated hardcoded values. Co-Authored-By: Warp <agent@warp.dev>
|
@copilot fix the CI errors |
|
@jaypatrick I've opened a new pull request, #255, to work on those changes. Once the pull request is ready, I'll request review from you. |
…ines Co-authored-by: jaypatrick <1800595+jaypatrick@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Implements a layered environment configuration approach for local development and CI by introducing committed base/env-specific .env files, a direnv-driven .envrc, and a reusable GitHub Actions composite action to load environment variables based on the branch.
Changes:
- Added committed
.env/.env.development/.env.productionplus updated.env.exampleand new.env.README.mdto document the layered configuration approach. - Added
.envrcfor automatic branch-to-environment mapping and layered env loading viadirenv. - Added a composite action (
.github/actions/setup-env) and wired it into CI to load env vars in GitHub Actions; updatedwrangler.tomlenv sections.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
wrangler.toml |
Adds env-specific sections and adjusts variable management; updates Hyperdrive local connection config. |
.gitignore |
Stops ignoring committed base env files while keeping local secrets ignored. |
.github/workflows/ci.yml |
Loads environment variables in CI jobs via the new composite action. |
.github/actions/setup-env/action.yml |
Composite action to detect environment from branch and load .env files into $GITHUB_ENV. |
.github/ENV_SETUP.md |
Documentation for using the composite action in workflows. |
.envrc |
direnv-based loader implementing branch-to-environment mapping and layered env loading. |
.env |
Base committed env defaults intended to be shared across environments. |
.env.development |
Development-specific env defaults (e.g., sqlite and Turnstile test keys). |
.env.production |
Production env template/defaults intended for main/master. |
.env.example |
Expanded template documenting available variables and setup. |
.env.README.md |
Repository-level documentation for the layered environment system. |
[WIP] Implement layered environment configuration system
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@jaypatrick I've opened a new pull request, #256, to work on those changes. Once the pull request is ready, I'll request review from you. |
- Fix GitHub Actions setup-env to properly parse dotenv files (strip quotes, handle comments) - Update .envrc to use direnv's built-in dotenv loader instead of custom function - Update .env COMPILER_VERSION from 0.8.3 to 0.11.4 to match deno.json - Remove DENO_DIR from base .env (breaks GitHub Actions on /app/.deno path) - Fix .env.production to use empty placeholders for Turnstile keys - Update .env.production documentation to clarify wrangler secret usage - Fix wrangler.toml localConnectionString to use real connection string template - Update .github/ENV_SETUP.md branch mapping table to match actual behavior - Fix .env.README.md to clarify .envrc should be committed - Update deno.json dev task to remove --env=.envrc flag (now handled by direnv) Co-authored-by: jaypatrick <1800595+jaypatrick@users.noreply.github.com>
Fix environment configuration parsing and documentation issues
|
@copilot fix the ci errors |
|
@jaypatrick I've opened a new pull request, #257, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: jaypatrick <1800595+jaypatrick@users.noreply.github.com>
Fix markdown formatting violations in .env.README.md
Overview
This PR implements a layered environment configuration system using
.envrcanddirenvfor automatic environment management based on git branches, with full GitHub Actions integration.Changes
Environment File Structure
.env- Base configuration shared across all environments (committed).env.development- Development-specific configuration (committed).env.production- Production configuration with placeholders (committed).env.local.env.local- Local overrides and secrets (NOT committed).env.example- Updated template with full documentation.envrc- Environment loading logic (committed)Loading Order
Environment variables are loaded in this order (later overrides earlier):
.env(base).env.$ENV(environment-specific).env.local(local overrides/secrets)Branch-to-Environment Mapping
The
.envrcautomatically determines environment from git branch:main/master→productiondev/develop→developmentlocalWrangler Integration
wrangler.tomlwith environment-specific configurations[env.development]and[env.production]sectionswrangler secret putGitHub Actions Integration
.github/actions/setup-env).envrcbehavior.envand.env.$ENVfiles into workflow.github/ENV_SETUP.md)Documentation
.env.README.mdwith comprehensive setup instructions.github/ENV_SETUP.mdfor GitHub Actions usageSecurity Improvements
.gitignoreto allow base config files while keeping secrets ignored.envrccommitted (contains no secrets, only loading logic).env.localnever committed (contains all secrets)Testing
devbranch (development).env.local(not committed).envrcproperly committed and loadableLocal Setup
GitHub Actions Usage
Wrangler Usage
Co-Authored-By: Warp agent@warp.dev