Travis CI is a popular CI/CD tool that is extremely user friendly. Travis CI also has a free tier for testing personal projects.
Our blog post goes over creating a CI/CD pipeline with Travis CI and deploying Cloudflare Workers with the Serverless framework.
Travis CI requires a
.travis.yml to be included in any repo that will use Travis. This file tells Travis how to run your build process. For those who are just looking for an example
.travis.yml please see the below:
language: node_js node_js: - "node" deploy: - provider: script script: sls deploy skip_cleanup: true on: branch: master
As you can see we are using the Serverless Framework to deploy the Worker, but you may specify any custom script. This
.travis.yml also assumes you are running unit tests (as Travis runs
npm test by default for Node projects).
You can skip tests altogether by adding:
In this case we have also added the
npm_modules to the
.gitignore file to prevent any conflicts.
To deploy with Travis, the first step is to sync Travis CI GitHub to pull in your Worker Repos. Travis has an excellent getting started tutorial here.
Once GitHub has access to Travis CI you have the option to grant Travis access to individual repos in your 'Overview' screen as show below. When you toggle the grey button 'on' to green, Travis will start listening for Webhooks on that repo. You'll also be able to customize the build settings and add things like
Please see below for example
ENV variable set up. In this case since we are deploying with Serverless, we set the
SLS_DEBUG variable for more verbose error messaging.
When you want Travis to run a pipeline for you, you must include a
.travis.yml file in the root of your repo. This is a configuration file that tells Travis what commands to run during your build process. A final repo layout (if you were running tests and deploying with Serverless) could look like:
----- worker.js ----- serverless.yml ----- test . worker-test.js ----- node_modules ----- package.json ----- package-lock.json ----- .travis.yml ----- .gitignore
For a more detailed run through of how to configure your repo and deploy with Serverless we suggest taking a look at the blog, which describes an entire CI/CD pipeline.