🧙‍♀️ easily deploy cloudflare workers applications using wrangler and github actions
Find a file
2019-10-14 15:58:48 -05:00
action.yml Add environment support, change input names 2019-10-14 15:24:54 -05:00
Dockerfile Updates from testing locally 2019-10-11 13:01:57 -05:00
entrypoint.sh Fix reversed environment env var check 2019-10-14 15:33:15 -05:00
LICENSE-APACHE Add README, licenses 2019-10-14 15:54:13 -05:00
LICENSE-MIT Add README, licenses 2019-10-14 15:54:13 -05:00
README.md Finish a thought 2019-10-14 15:58:48 -05:00

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/wrangler-action@0.1.0
      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/wrangler-action@0.1.0
      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/wrangler-action@0.1.0
      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/wrangler-action@0.1.0
      with:
        apiKey: ${{ secrets.CLOUDFLARE_API_KEY }}
        email: ${{ secrets.CLOUDFLARE_EMAIL }}