Example project on how to build to deploy to Cloudflare Workers using the Serverless framework.
In order to deploy, you must have a domain active in Cloudflare.
- Fork this repository and create a project on Semaphore.
- Go to your Cloudflare account domain. In Overview look for the Zone ID and the Account ID.
- Go to Get your API Key. Copy the authorized email.
- Go to API Tokens. Click on View next to Global API Key. Copy the displayed key.
- Add a secret on Semaphore as detailed in the next section.
- Edit
serverless.yml
. Edit theurl
key with the route that you want to trigger the function. The URL must contain your domain name.... events: - http: url: example.com/hello method: GET ...
- Push to GitHub.
This is how the complete workflow looks:
Create a secret on Semaphore with your Cloudflare details:
$ sem create secret cloudflare \
-e CLOUDFLARE_AUTH_EMAIL=YOUR_EMAIL \
-e CLOUDFLARE_AUTH_KEY=YOUR_API_KEY \
-e CLOUDFLARE_ACCOUNT_ID=YOUR_ACCOUNT_ID \
-e CLOUDFLARE_ZONE_ID=YOUR_ZONE_ID
You can also run the tests on your dev machine, for this, install Node.js and nvm.
$ nvm use
$ npm install
$ npm run lint
$ npm test
Copyright (c) 2019 Rendered Text
Distributed under the MIT License. See the file LICENSE.md.