GitHub Action
Deploy to Cloudflare Workers with Wrangler
✨ Zero-config Cloudflare Workers deployment using Wrangler and GitHub Actions
Add wrangler-action
to the workflow for your Workers application. The below example will publish your application on pushes to the master
branch:
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@master
- name: Publish
uses: signalnerve/[email protected]
with:
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
email: ${{ secrets.CLOUDFLARE_EMAIL }}
You'll need to configure Wrangler using GitHub's Secrets feature - go to "Settings -> Secrets" and add your Cloudflare API key and email (for help finding these, see the Workers documentation). Your API key and email are encrypted by GitHub, and the action won't print them into logs, so they should be safe!
With your API key and email set as secrets for your repository, pass them to the action in the with
block of your workflow:
jobs:
deploy:
name: Deploy
steps:
uses: signalnerve/[email protected]
with:
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
email: ${{ secrets.CLOUDFLARE_EMAIL }}
Optionally, you can also pass an environment
key to the action. If you're using Wrangler's environments feature, you can customize where the action deploys to by passing the matching environment in the with
block of your workflow:
jobs:
deploy:
# ... previous configuration ...
steps:
uses: signalnerve/[email protected]
with:
# ... api key and email ...
environment: "production"
This action is in beta, and I'm looking for folks to use it! If something goes wrong, please file an issue! That being said, there's a couple things you should know:
No problem! Check out the Quick Start guide in our docs to get started. Once you have a Workers application, you may want to set it up to automatically deploy from GitHub whenever you change your project. That's where this action comes in - nice!
To deploy static sites and frontend applications to Workers, check out the documentation for Workers Sites.
Note that this action makes no assumptions about how your project is built! If you need to run a pre-publish step, like building your application, you need to specify a build step in your Workflow. For instance, if I have an NPM command called build
, my workflow TOML might resemble the following:
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@master
- name: Build site
run: "npm run build"
- name: Publish
uses: signalnerve/[email protected]
with:
apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
email: ${{ secrets.CLOUDFLARE_EMAIL }}