Cloudflare Workers Deployment

Cloudflare Workers is an excellent option as a CDN for deploying your Greenwood site, though if you are new to using this service consider deploying with Netlify as it is a simpler process.

This will require a paid account with Cloudflare (currently $5 per month) with a linked domain for custom domain and subdomains.


You will need to globally install Cloudflare's CLI tool Wrangler

yarn add global @cloudflare/wrangler

In the root of your project directory initialize Wrangler

wrangler init

Authenticate your cloudflare account with:

wrangler config

A wrangler.toml file was generated at the root of your project directory, update it like this...

name = "demo" // subdomain name automatically named for the directory
type = "webpack"
account_id = "abcd12345...." //your account id

workers_dev = true

bucket = "./public" //where greenwood generated the compiled code
entry-point = "workers-site"

Compile your code

greenwood build

Then push your code to Cloudflare workers

wrangler publish

When completed a url for workers subdomain will be printed in your terminal.

To have automatic deployments whenever you push updates to your repo, you will need to configure GitHub actions to accomplish this, otherwise you can push updated manually but running the build and publish commands each time you wish to update the site.

Automatic Deployments with GitHub Actions

Add the email address associated with your account and your global api key from Cloudflare to the repositories GitHub secrets.

At the root of your project add '.github/workflows/main.yml'

name: Deploy production site

        - master
   runs-on: ubuntu-latest
      - uses: actions/checkout@v1
      - name: Navigate to repo
        run: cd $GITHUB_WORKSPACE
      - name: Install Chromium Library Dependencies
        run: |
         sh ./.github/workflows/
      - uses: actions/setup-node@v1
           node-version: "10.x"
      - name: Install deps
        run: npm install
      - name: Build docs
        run: npm run build
      - name: Publish
        uses: cloudflare/wrangler-action@1.1.0
           apiKey: ${{ secrets.CF_WORKERS_KEY }}
           email: ${{ secrets.CF_WORKERS_EMAIL }}
           environment: "production"

In the same directory as main.yml create a file ''


sudo apt-get update 
  && sudo apt-get install -yq libgconf-2-4 
  && sudo apt-get install -y wget --no-install-recommends 
  && sudo wget -q -O - | sudo apt-key add - 
  && sudo sh -c 'echo "deb [arch=amd64] stable main" >> /etc/apt/sources.list.d/google.list' 
  && sudo apt-get update 
  && sudo apt-get install -y google-chrome-unstable --no-install-recommends 
  && sudo rm -rf /var/lib/apt/lists/*

Push your updates to your repo and the action will begin automatically. This will create a new worker with the name from the toml file -production (IE demo-production), make sure custom url is attached to this worker.