Skip to content

Support GitHub deployments for Cloudflare Workers #377

@suhailskhan

Description

@suhailskhan

This action has a feature that creates GitHub Deployments when deploying to Cloudflare Pages.

From README:

Deploy your Pages site (production & preview)

If you want to deploy your Pages project with GitHub Actions rather than the built-in continous integration (CI), then this is a great way to do it. Wrangler 2 will populate the commit message and branch for you. You only need to pass the project name. If a push to a non-production branch is done, it will deploy as a preview deployment:

on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Deploy
    permissions:
      contents: read
      deployments: write
    steps:
      - uses: actions/checkout@v4
      - name: Deploy
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          command: pages deploy YOUR_DIST_FOLDER --project-name=example
          # Optional: Enable this if you want to have GitHub Deployments triggered
          gitHubToken: ${{ secrets.GITHUB_TOKEN }}

As seen from the comment towards the end of the YAML snippet, passing GITHUB_TOKEN with the deployments: write permission to the action will allow it to trigger GitHub Deployments.

I wrote this workflow which is configured the same way as the example above, except it deploys to Workers instead of Pages.

The result is a successful Workers deployment, but the action does not trigger a deployment in any environment in my GitHub repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions