Skip to content

Commit

Permalink
ci: preview step writes next env vars to .env (#26)
Browse files Browse the repository at this point in the history
because @cloudflare/next-on-pages doesn't pass through env vars
  • Loading branch information
gobengo authored Nov 6, 2023
1 parent 593d330 commit 33bbc95
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/console/.github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,27 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- name: create .env from .env.tpl setting env variables used by `pnpm run build`
- name: create .env from .env.tpl setting env variables used by `pnpm run pages:build`
run: |
# set env vars from template
# omit these because they are added manually in the next step
function excludeDefaultServiceVariables() {
cat - | grep -v NEXT_PUBLIC_SERVICE_ | grep -v NEXT_PUBLIC_W3UP_PROVIDER
cat - | grep -v NEXT_PUBLIC_W3UP_SERVICE_
}
# set .env from .env.tpl with exclusions
cat .env.tpl | excludeDefaultServiceVariables > .env
# add vars configuring console frontend to use staging w3up as backend
echo "NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:staging.web3.storage" >> .env
echo "NEXT_PUBLIC_W3UP_SERVICE_URL=https://staging.up.web3.storage" >> .env
echo "NEXT_PUBLIC_W3UP_PROVIDER=did:web:staging.web3.storage" >> .env
# as long as this uses https://github.com/cloudflare/next-on-pages/blob/dc529d7efa8f8568ea8f71b5cdcf78df89be6c12/packages/next-on-pages/bin/index.js,
# env vars won't get passed through to wrangler, so if wrangler will need them, write them to .env like the previous step
- run: pnpm pages:build
env:
NEXT_PUBLIC_SERVICE_DID: 'did:web:staging.web3.storage'
NEXT_PUBLIC_SERVICE_URL: 'https://staging.up.web3.storage'
NEXT_PUBLIC_W3UP_PROVIDER: 'did:web:staging.web3.storage'
- run: cat .env
- run: grep -o ".\{0,50\}staging.web3.storage.\{0,50\}" -R .vercel
- name: Deploy preview build to Cloudflare Pages
uses: mathiasvr/command-output@v1.1.0
id: cloudflare
Expand Down

0 comments on commit 33bbc95

Please sign in to comment.