Cloudflare DevelopersCD
Cloudflare Developersβ€’7mo agoβ€’
6 replies
Zwel

Can't use env from cloudflare in deployed workers with ci/cd

My Wrangler GitHub Action isn't applying environment variables set in the Cloudflare dashboard to deployments made by uploading the dist folder. The Action seems to require a build step first, but even after building, the uploaded dist content doesn't access the dashboard-configured environment variables.

jobs:
  deploy:
    env:
      CLOUDFLARE_ENV: staging
      MY_SECRET: ${{ secrets.MY_SECRET }} // I've already added to cloudflare dashboard but can't access from my deployed version

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions

      - name: Build project
        run: bun run build // Do I really need to build first?

      - name: Deploy Worker
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Was this page helpful?