Skip to content

Fix environment configuration parsing and documentation issues#256

Merged
jaypatrick merged 2 commits intofeature/env-configurationfrom
copilot/sub-pr-254
Feb 3, 2026
Merged

Fix environment configuration parsing and documentation issues#256
jaypatrick merged 2 commits intofeature/env-configurationfrom
copilot/sub-pr-254

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Addresses 11 issues from PR #254 review: broken dotenv parsing in GitHub Actions, quote handling in .envrc, version mismatches, and misleading documentation.

Dotenv Parsing

GitHub Actions - Replaced grep with proper parser that strips quotes and handles edge cases:

# Before: quotes preserved literally, comments break GITHUB_ENV
grep -v '^#' .env >> $GITHUB_ENV

# After: proper parsing with quote stripping
while IFS= read -r line; do
  [[ "$line" =~ ^[A-Za-z_][A-Za-z0-9_]*= ]] || continue
  key="${line%%=*}"
  value="${line#*=}"
  # Strip surrounding quotes
  [[ "$value" =~ ^[\"'](.*)[\"']$ ]] && value="${BASH_REMATCH[1]}"
  echo "$key=$value" >> $GITHUB_ENV
done < .env

.envrc - Use direnv's built-in loader instead of custom function:

# Before: custom function with quote issues
load_env_file() { while IFS='=' read -r key value; do export "$key"="$value"; done < "$1"; }

# After: use direnv's proper implementation
dotenv_if_exists ".env"
dotenv_if_exists ".env.$ENV"

Configuration Fixes

  • COMPILER_VERSION: 0.8.30.11.4 (sync with deno.json)
  • DENO_DIR: Removed from base .env (/app/.deno breaks GitHub Actions)
  • Turnstile keys: Empty values in .env.production (prevent accidental verification)
  • wrangler.toml: Fixed localConnectionString to actual template vs env var name
  • deno.json: Removed --env=.envrc flag (now direnv script, not dotenv file)

Documentation

  • ENV_SETUP.md: Corrected branch mapping table (shows .env + .env.$ENV loaded, not just env-specific)
  • .env.production: Clarified production secrets use wrangler secret put, not .env.local
  • .env.README.md: Fixed contradictory guidance (.envrc should be committed, never contains secrets)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- 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>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 3, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
adblock-compiler 78cadd7 Feb 03 2026, 09:02 PM

Copilot AI changed the title [WIP] Implement layered environment configuration system Fix environment configuration parsing and documentation issues Feb 3, 2026
Copilot AI requested a review from jaypatrick February 3, 2026 21:02
@jaypatrick jaypatrick marked this pull request as ready for review February 3, 2026 21:03
@jaypatrick jaypatrick merged commit 2512dab into feature/env-configuration Feb 3, 2026
1 check passed
@jaypatrick jaypatrick deleted the copilot/sub-pr-254 branch February 3, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants