Skip to content

Commit

Permalink
🎨 Secrets support
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Jul 2, 2023
1 parent 6656020 commit cf0a6ed
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ jobs:
uses: cloudflare/wrangler-action@2.0.0
with:
workingDirectory: ./apps/api
command: |
deploy ./src/index.ts --experimental-json-config --config='wrangler.json' --latest
wranglerVersion: 'beta'
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
preCommands: echo "Deploying API to Cloudflare Workers"
command: deploy ./src/index.ts --experimental-json-config --config='wrangler.json' --latest
postCommands: echo "Deployed API to Cloudflare Workers"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
INFURA_KEY
LLAMANODES_API_KEY
ANKR_API_KEY
CHAINNODES_API_KEY
SENTRY_DSN
env:
NODE_ENV: 'production'
INFURA_KEY: ${{ secrets.INFURA_KEY }}
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ app.onError((error, context) => {

app.get('/env', context => {
const environmentVariables = env(context)
console.log(JSON.stringify(environmentVariables, undefined, 2))
if (environmentVariables['NODE_ENV'] !== 'development') return context.json({ NODE_ENV: 'production' }, 200)
return context.text(JSON.stringify(environmentVariables, undefined, 2))
})
Expand Down
3 changes: 3 additions & 0 deletions apps/api/wrangler.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"compatibility_date": "2023-06-20",
"compatibility_flags": ["nodejs_compat"],
"placement": { "mode": "smart" },
"vars": {
"NODE_ENV": "production"
},
"env": {
"production": {
"vars": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/example/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { getAddress, http } from 'viem'
import { mainnet } from 'viem/chains'
import { createPublicClient } from 'viem'
import { BALANCES_OF_ABI } from '../abi'
import { BALANCES_OF_ABI } from '../abi'

main()
.then(console.log)
Expand Down

0 comments on commit cf0a6ed

Please sign in to comment.