Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
cloudflare

GitHub Action

Deploy to Cloudflare Workers with Wrangler

0.1.3

Deploy to Cloudflare Workers with Wrangler

cloudflare

Deploy to Cloudflare Workers with Wrangler

Deploy your Cloudflare projects from GitHub using Wrangler

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Deploy to Cloudflare Workers with Wrangler

uses: cloudflare/[email protected]

Learn more about this action in cloudflare/wrangler-action

Choose a version

Wrangler GitHub Action

✨ Zero-config Cloudflare Workers deployment using Wrangler and GitHub Actions

Usage

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 }}

Configuration

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"

Troubleshooting

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:

"I just started using Workers/Wrangler and I don't know what this is!"

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!

"I'm trying to deploy my static site but it isn't working!"

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 }}