Configure builds on Travis CI
Caution
Travis CI support on the WordPress VIP platform will be deprecated in the near future.
We recommend using Circle CI instead.
It’s a good idea to read the Travis CI getting started documentation, but don’t add the Travis CI config at this point.
- Visit https://travis-ci.com, authenticate with your GitHub account, and add your repository to Travis CI
- Create or adapt a config for Travis CI:
- If you have no Travis CI config in your repository, copy this config to
.travis.yml
in your repo; you will need to add the build command(s) you’re using in the section under “@TODO: Configure build steps” - If you already have a config, you’ll need to:
- Add the build command(s), referencing the
before_script
section in our example config commented with “@TODO: Configure build steps” - Add the two sets of two lines referenced by the “REQUIRED:” comments
- Add the build command(s), referencing the
- If you have no Travis CI config in your repository, copy this config to
- Ensure you have a machine user, this is a regular GitHub user account which is used purely for scripted functions, e.g. used by Travis CI to commit and push the built code (GitHub call this user a “machine user”):
- If you have no dedicated “machine user” account, create a new GitHub account, named appropriately.
- If you already have a machine user for your team, then use that account for the following steps.
- Setup a key pair for your machine user:
- Use the command line on your local machine to create a public private key pair (documentation)
- Set the public portion of the key pair as a deploy key with write permissions on the GitHub repository (documentation)
- Add the private key as a setting on your Travis repository (see “Adding a deploy key in repository settings on Travis CI” below)
- If necessary, add and update a
.deployignore
file. - Merge a PR to your
master
branch… it should be built by Travis CI, committed to yourmaster-built
branch, and pushed up to GitHub (verify the branch now exists on GitHub and contains the changes you made) - Contact VIP to have your environment changed to deploy from
master-built
- …that’s it!
Adding a deploy key as a repository variable on Travis CI
Caution
Please read these instructions through completely before executing the steps.
- Add the public portion of the key as a deploy key on your GitHub repository; GitHub documentation on deploy keys.
- Set the private portion of the key as a repository variable in the Travis settings. You will need to replace newlines with
\n
and surround it with double quotes, e.g. “THIS\nIS\A\KEY\nABC\n123\n”; Travis documentation on repository variables in settings. - You must set the “Display value in build log” toggle for the repository variable to “off”.
- You must name the Travis setting that contains the key
BUILT_BRANCH_DEPLOY_KEY
.