cloudflare / wrangler-action

🧙‍♀️ easily deploy cloudflare workers applications using wrangler and github actions
Apache License 2.0
1.26k stars 159 forks source link

Is there are a better way to use wrangler.toml file with wrangler-action? #285

Closed shakibhasan09 closed 1 week ago

shakibhasan09 commented 3 months ago
      - name: Deploy Pages
        uses: cloudflare/wrangler-action@v3
        with:
          preCommands: |
            cp wrangler.toml.example wrangler.toml
            sed -i 's|\bdatabase_id\b = ".*"|database_id = "${{ vars.DB_DATABASE_ID }}"|g' wrangler.toml
            sed -i 's|database_name = ".*"|database_name = "${{ vars.DB_DATABASE_NAME }}"|g' wrangler.toml
            pnpm pages:build

          command: pages deploy
          workingDirectory: apps/web
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}

Are there any way we can use wrangler bindings instead of using sed? I'm not pushing the wrangler.toml file.

shahsimpson commented 1 week ago

You should be able to add --var ${{ vars.DB_DATABASE_ID }} = database_id to the end of the command. https://developers.cloudflare.com/workers/wrangler/commands/#deploy