Giter VIP home page Giter VIP logo

cloudflare-worker-action's Introduction

Github Action to Deploy a Cloudflare Worker with the Serverless Framework

If you are new to GitHub actions please see the official guide here.

To use this action you must provide a Worker script (i.e. worker-script.js) in your repo attached to this action as well as the appropriate environmental variables.

File Structure

Your repo must include the CF Worker script to be deployed and an optional serverless.yml file. If you do not include a serverless.yml file then the action will assume some smart defaults to deploy the worker based on the ENV variables you pass. Any included serverless.yml must exist in the root of your repo along with your worker script.

Environmental Variables

This action will expect the following environmental variables to be passed:

CLOUDFLARE_AUTH_EMAIL #the email associated with the accout
CLOUDFLARE_ACCOUNT_ID #your account ID
CLOUDFLARE_ZONE_ID #your Cloudflare zone ID
CLOUDFLARE_AUTH_KEY #your global API key; use the secret variable type available within GitHub Actions for this variable
CLOUDFLARE_SCRIPT_NAME #the name of your worker-script.js file with .js ommited. NOTE: Worker names can contain lowercase letters, numbers, underscores, and dashes. They cannot start with dashes or contain uppercase letters.

Using a Custom Serverless.yml

The Serverless framework expects a serverless.yml file which allows us to use our existing Serverless integration to deploy Workers for this GitHub action. By default we provide one to deploy your worker. If you'd like to bring your own, please see here for getting started.

You may pass in other environmental variables to your custom serverless.yml if needed just make sure to refer to them by using ${env:YOUR_VARIABLE} syntax.

In a multiscript (Enterprise) environment the name will be seen in the UI where all your scripts are listed. In a single script environment the name will not be shown in the UI (as there is only one script).

main.workflow

The main.workflow output could look something like:

workflow "Depkoy Worker {
  on = "push"
  resolves = ["cloudflare/serverless-action@master"]
}

action "Deploy Worker" {
  uses = "cloudflare/serverless-action@master"
  env = {
    CLOUDFLARE_ACCOUNT_ID = "ACCOUNT_ID"
    CLOUDFLARE_ZONE_ID = "ZONE_ID"
    CLOUDFLARE_AUTH_EMAIL = "[email protected]"
    CLOUDFLARE_SCRIPT_NAME = "worker-script"
  }
  secrets = ["CLOUDFLARE_AUTH_KEY"]
}

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.

cloudflare-worker-action's People

Contributors

jakejarvis avatar tombrightbill avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.