Skip to content

Commit 3b2d800

Browse files
ILindsleyclaude
andcommitted
Remove secrets from code, inject via GitHub Actions
Secrets are now stored in GitHub Actions secrets and injected at deploy time - never committed to repo. Required GitHub secrets: - AUTH_SECRET (generate with: openssl rand -base64 32) - ENGINE_API_KEY (get new key - old one was rotated) - GOOGLE_CLIENT_ID (for Google OAuth) - GOOGLE_CLIENT_SECRET (for Google OAuth) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 72d2cdd commit 3b2d800

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.github/workflows/deploy-cloudflare.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@ jobs:
2121
- name: Install dependencies
2222
run: npm ci
2323

24+
- name: Inject secrets into wrangler config
25+
run: |
26+
node -e "
27+
const fs = require('fs');
28+
let content = fs.readFileSync('wrangler.jsonc', 'utf8');
29+
// Remove comments for JSON parsing
30+
const config = JSON.parse(content.replace(/\/\/.*$/gm, '').replace(/,(\s*[}\]])/g, '\$1'));
31+
config.vars = {
32+
...config.vars,
33+
AUTH_SECRET: process.env.AUTH_SECRET,
34+
ENGINE_API_KEY: process.env.ENGINE_API_KEY,
35+
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID || '',
36+
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET || ''
37+
};
38+
fs.writeFileSync('wrangler.jsonc', JSON.stringify(config, null, 2));
39+
"
40+
env:
41+
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
42+
ENGINE_API_KEY: ${{ secrets.ENGINE_API_KEY }}
43+
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
44+
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
45+
2446
- name: Build for Cloudflare
2547
run: npx opennextjs-cloudflare build
2648

wrangler.jsonc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
},
1111
"vars": {
1212
"AUTH_TRUST_HOST": "true",
13-
"AUTH_SECRET": "***REDACTED_AUTH_SECRET***",
1413
"ENGINE_BASE_URL": "https://api.btservant.ai",
15-
"ENGINE_API_KEY": "***REDACTED_ENGINE_API_KEY***",
1614
"CLIENT_ID": "web",
1715
"DEFAULT_ORG": "unfoldingWord"
1816
}
17+
// Secrets injected at deploy time via GitHub Actions:
18+
// - AUTH_SECRET
19+
// - ENGINE_API_KEY
20+
// - GOOGLE_CLIENT_ID
21+
// - GOOGLE_CLIENT_SECRET
1922
}

0 commit comments

Comments
 (0)