Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliperelman/now-travis
https://github.com/eliperelman/now-travis
now travis-ci zeit
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eliperelman/now-travis
- Owner: eliperelman
- Created: 2017-01-23T15:46:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-30T15:14:02.000Z (about 7 years ago)
- Last Synced: 2024-11-01T21:47:18.434Z (2 months ago)
- Topics: now, travis-ci, zeit
- Language: JavaScript
- Size: 145 KB
- Stars: 48
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# now-travis
Automatically deploy to ∆ Now from Travis pushes. Setting up now-travis can:
- Automatically create staging deployments for pull requests
- Automatically deploy and alias upon pushes to masterWarning: Using now-travis has the potential to create many deployments, enough to blow
through the allotment on the Free plan. It is recommended to only use this on the Pro or
Enterprise accounts.## Setup
In order to use now-travis on a repository, you'll need some keys to authorize it to execute
actions in Travis. The following set up will walk you through this process.First, you'll need to create a [New personal access token](https://github.com/settings/tokens/new). Give
the token a name, and check the `repo` scope checkbox. This will only be used to set the status on pull requests
with a ∆ Now URL. Be sure to keep this key ready to paste into an upcoming command.Second, head over to [Zeit's API tokens page](https://zeit.co/account#api-tokens) and create a new token. This
will be used to create deployments during pull requests and master pushes.If your repository doesn't have a `.travis.yml` file, create an empty one now in the root of the repo.
Now we need to encrypt the API keys we generated into the `.travis.yml` file. This is done using a CLI tool. You can
either install the [travis-ci tool](https://github.com/travis-ci/travis.rb) or the [travis-encrypt npm tool](https://www.npmjs.com/package/travis-encrypt)
for encrypting these values.If you are using the travis-ci tool, execute the following command in your terminal, substituting ``, ``,
``, and `` with the appropriate values:```sh
travis encrypt -r / GH_TOKEN= NOW_TOKEN= --add
```If you are using the travis-encrypt tool from npm, execute the following command in your terminal, substituting ``, ``,
``, and `` with the appropriate values:```sh
travis-encrypt --add -r / GH_TOKEN= NOW_TOKEN=
```Your API keys are now encrypted in your `.travis.yml` file. Next, install now-travis in your project:
```sh
# Execute if using npm
npm install --save-dev now-travis# Execute this instead if you are using yarn
yarn add --dev now-travis
```Let's edit the `.travis.yml` file to automate deployments:
1. Add `after_script` to execute now-travis after the build is done and successful. If you use an alias for
your production deployments, add that to the `NOW_ALIAS` environment variable:```yaml
after_script:
- NOW_ALIAS=myalias.com node_modules/.bin/now-travis
```2. Add `branches` to ensure we only create production deployments when pushing to the master branch:
```yaml
branches:
only:
- master
```## Deployment
When creating pull requests after a Travis build has been successfully completed, now-travis will create a ∆ Now deployment
and update the pull request with the staging URL:![Screenshot](screenshot.png)
Clicking on the "Details" link will open the page to the staging deployment URL.
If you want to get the staging URL in subsequent steps of your Travis build, e.g running a [lighthouse-ci](https://github.com/ebidel/lighthouse-ci) test on the stage build, you can instruct `now-travis` to write the URL in a file by passing a `file` argument with the name of the file.
```yaml
- NOW_ALIAS=myalias.com node_modules/.bin/now-travis --file=now-staging-url
```With this, the staging URL will be written to a file named `now-staging-url`.
When pushing commits to master, now-travis will deploy the build to ∆ Now and alias the deployment using the value specified
in the `NOW_ALIAS` environment variable. This environment variable is only used on pushes, not pull requests.## Notes
While this module has been tested, it may not work perfectly in every Travis deployment situation. Please test
it out and report any issues that may arise.Again, this package has the ability to create many deployments, potentially more than your Zeit plan allots. Please
exercise judgement when installing this. By default, following these instructions for now-travis will create a deployment:- When a pull request is opened
- When a pull request is re-opened
- When a new commit is pushed to a pull request
- When a commit is pushed to the master branch