Production Deployment
Either;
Change
.env
and replace theWEBFLOW_WORKSPACE_API_TOKEN
, orChange
webflow.json
andappend " TEST" to the
library.name
and "-test" to the
library.id
Github Actions Approach
Branch-conditioned CI
Per-env secrets; generate .env
/ patch webflow.json
at build time. For local dev, auto-switch with a git hook.
Create two secrets in the repo: WF_TOKEN_PROD
and WF_TOKEN_PREVIEW
.
# .github/workflows/deploy.yml
name: deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
# choose token by branch
WEBFLOW_WORKSPACE_API_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.WF_TOKEN_PROD || secrets.WF_TOKEN_PREVIEW }}
steps:
- uses: actions/checkout@v4
# write .env for the job
- run: |
cat > .env <<EOF
WEBFLOW_WORKSPACE_API_TOKEN=${WEBFLOW_WORKSPACE_API_TOKEN}
EOF
# patch webflow.json per branch
- if: github.ref == 'refs/heads/main'
run: |
jq '.library.name="Sygnal Library" | .library.id="lib_prod_id"' webflow.json > w.json && mv w.json webflow.json
- if: github.ref != 'refs/heads/main'
run: |
jq '.library.name="Sygnal Library (Preview)" | .library.id="lib_preview_id"' webflow.json > w.json && mv w.json webflow.json
# …build/deploy steps here
Env approach
If you prefer Environments, put the secrets under production
(main) and preview
(non-main) and gate with if:
.
Keep local files out of Git
# .gitignore
.env
webflow.json
Commit templates only:
.env.example
webflow.main.json
webflow.preview.json
Auto-switch locally on branch change (Windows-friendly)
tools/sync-env.ps1
$branch = (git rev-parse --abbrev-ref HEAD).Trim()
$mode = if ($branch -eq 'main') { 'main' } else { 'preview' }
Copy-Item -Force ".env.$mode" ".env"
Copy-Item -Force "webflow.$mode.json" "webflow.json"
Write-Host "Synced env for branch '$branch' -> $mode"
.git/hooks/post-checkout
(sh)
#!/bin/sh
pwsh -File tools/sync-env.ps1
(make executable: git update-index --chmod=+x .git/hooks/post-checkout
)
Notes
Never commit real tokens.
If you need per-branch preview names/IDs, encode branch in the preview values (e.g.,
"Sygnal Library ($GITHUB_REF_NAME)"
) by templating before patching.
Last updated