Support GitHub deployments for Cloudflare Workers
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.
Hmm this isn't correct AFAIK - you can use this to deploy to workers
@CyberFlameGO That is not what I said. Of course this action is able to deploy to Workers as well as Pages.
I am referring to this action's ability to create a deployment in the "Environments" section of a GitHub repository. This functionality only works when performing a Pages deployment, and does not work when doing a Workers deployment.
The image below shows what a deployment looks like on a GitHub repository page. If you are using this action to deploy to Pages and you pass GITHUB_TOKEN to it, you will start seeing an active deployment in the "Environments" section of the repository details column. This feature is what the README snippet I showed above is intended to document.
More information: https://docs.github.com/en/repositories/viewing-activity-and-data-for-your-repository/viewing-deployment-activity-for-your-repository
Upon reading the issue description again, I can see it is lacking specific details and is rather vague. I will revise it. Thank you for the comment, @CyberFlameGO
Experiencing the same issue. I have configured secrets.GITHUB_TOKEN, but the job does not create a deployment on GitHub.
name: PRODUCTION
on:
push:
branches:
- main
jobs:
deploy:
name: deploy application
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: setup package manager
uses: pnpm/action-setup@v4
with:
run_install: false
- name: install node
uses: actions/setup-node@v4
with:
cache: 'pnpm'
check-latest: true
node-version-file: '.nvmrc'
- name: install dependencies
run: pnpm install
- name: build application
run: pnpm run build
- name: deploy application
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
workingDirectory: '.output/'
command: deploy
The actual deployment to Cloudflare works, but it's not created in GitHub.