Skip to content

Latest commit

 

History

History
97 lines (64 loc) · 3.49 KB

travis-ci.md

File metadata and controls

97 lines (64 loc) · 3.49 KB

Travis CI

Documentation Changes

If you do not want to build the pipeline because all you are changing is the README.md file, us [ci skip] in the commit message.

Pipeline

Travis CI Setup

Travis CI build expects the following environment variables:

  • AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY: AWS credentials used for deploying
  • STAGING_BUCKET and STAGING_BUCKET_REGION: S3 bucket and Region for Staging environment
  • PROD_BUCKET and PROD_BUCKET_REGION: S3 bucket and Region for Production environment

Configuring Travis CI to Publish to NPM

Verify you have ruby version > 1.9.3:

> ruby -v
> ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

Install the Travis CI CLI:

> gem install travis -v 1.8.8 --no-rdoc --no-ri

NOTE: It may be necessary to have XCode CLI if working on a Mac

> xcode-select --install

Edit your .travis.yml file to have a deploy provider:

- provider: npm
  email: <BUILDIT_NPM_USER_EMAIL_ADDRESS>
  api_key: 
    secure: <ENCRYPTED_NPM_AUTH_TOKEN> (*)
  on:
    repo: <GIT_REPO_NAME> (e.g. buildit/buildit for the Buildit Website)
    branch: <TARGETED_BRANCH>
    tags: <TRUE_OR_FALSE> (Whether to build on Tags)
    condition: <CONDITION_TO_ACTIVATE_ON> (i.e. a regex)

  ...<ANY_OTHER_OPTIONS>... 

* Generated using Travis-CI CLI, read below or click see here

Travis Encryption of API Key for NPM

Travis needs to have access to the Buildit NPM account to be able to push the new artefacts to the NPM registry. As this is a public project it was decided to use a generic user account on NPM. The API key is then generated and linked to this account.

NOTE: To generate or protect the API key, it is required to have the Travis-CI CLI tool installed. Please see above for details.

You must be logged-in on your NPM CLI instance in order to link your CLI environment to your remote Buildit NPM account. The following command will update your .npmrc file in your personal home directory once you have entered in all the security information:

> npm login

After successful log on, navigate to your npmrc file (e.g. on a mac /Users/<user>/.npmrc), to retrieve the generated API key for the next steps.

You must be logged-in on the Travis-CI CLI in order to link your CLI environment to your remote Travis-CI.org account:

> travis login --auto

Run the following command to encrypt the NPM API key:

> travis encrypt <API_KEY> -r buildit/gravity-ui-web --org

NOTE: Do not use the --add env.global or any other permutation to the travis encrypt command, as it may overwrite other variables in your .travis.yml file.

Deployment

Currently, deployment only means synchronising the output of the build with an S3 bucket.

S3 buckets and DNS have to be set up manually.