All Projects β†’ semantic-release β†’ travis-deploy-once

semantic-release / travis-deploy-once

Licence: MIT license
🚫Test multiple node versions on Travis. Deploy once. If all of them pass.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to travis-deploy-once

Travis cpp tutorial
Tutorial how to use Travis CI with C++
Stars: ✭ 178 (+423.53%)
Mutual labels:  travis-ci, travis
Generator Rn Toolbox
The React Native Generator to bootstrap your apps
Stars: ✭ 1,155 (+3297.06%)
Mutual labels:  travis-ci, travis
Cargo Make
Rust task runner and build tool.
Stars: ✭ 895 (+2532.35%)
Mutual labels:  travis-ci, travis
Fetch Suspense
A React hook compatible with React 16.6's Suspense component.
Stars: ✭ 479 (+1308.82%)
Mutual labels:  travis-ci, travis
Ci Detector
Detect continuous integration environment and get information of current build
Stars: ✭ 138 (+305.88%)
Mutual labels:  travis-ci, travis
Use React Router
React Hook for pub-sub behavior using React Router.
Stars: ✭ 575 (+1591.18%)
Mutual labels:  travis-ci, travis
Quicksort Js
An implementation of Quicksort in JavaScript/TypeScript.
Stars: ✭ 60 (+76.47%)
Mutual labels:  travis-ci, travis
googletest-ci
Continuous integration (CI) + Google Test (gtest) + CMake example boilerplate demo
Stars: ✭ 14 (-58.82%)
Mutual labels:  travis-ci, travis
Trytravis
Send local git changes to Travis CI without commits or pushes.
Stars: ✭ 131 (+285.29%)
Mutual labels:  travis-ci, travis
Travis Scripts
πŸ™… DEPRECATED
Stars: ✭ 119 (+250%)
Mutual labels:  travis-ci, travis
react-innertext
Returns the innerText of a React JSX object.
Stars: ✭ 37 (+8.82%)
Mutual labels:  travis-ci, travis
Use Force Update
React Hook to force your functional component to update.
Stars: ✭ 142 (+317.65%)
Mutual labels:  travis-ci, travis
todo-list
TodoList using Ionic2/3 & Firebase: * PWA * SSO Google plus. * Share list via QRcode. * Upload image from Camera or Storage. * Speech Recognition.
Stars: ✭ 18 (-47.06%)
Mutual labels:  travis-ci, travis
vagrant-travisci-libvrt
Example project showing how to run Vagrant on TravisCI using libvrt & KVM
Stars: ✭ 25 (-26.47%)
Mutual labels:  travis-ci, travis
react-multi-context
Manage multiple React 16 contexts with a single component.
Stars: ✭ 19 (-44.12%)
Mutual labels:  travis-ci, travis
Condition Travis
🚫 semantic-release plugin to check Travis CI environment before publishing.
Stars: ✭ 9 (-73.53%)
Mutual labels:  travis-ci, travis
badge-matrix
More advanced badges for projects using Travis or Sauce Labs
Stars: ✭ 77 (+126.47%)
Mutual labels:  travis-ci, travis
yaspeller-ci
Fast spelling check for Travis CI
Stars: ✭ 60 (+76.47%)
Mutual labels:  travis-ci, travis
Realm Browser
Android Database Browser for realm-java
Stars: ✭ 101 (+197.06%)
Mutual labels:  travis-ci, travis
Use Clippy
React Hook for reading from and writing to the user's clipboard.
Stars: ✭ 139 (+308.82%)
Mutual labels:  travis-ci, travis

travis-deploy-once

Run a deployment script only once in the Travis test matrix.

Travis Codecov Greenkeeper badge

⚠️ Deprecation Notice ⚠️

This library is deprecated and will not be maintained. We recommend to use Build Stages instead. It’s a clearer and more flexible way to orchestrate jobs within a build.

Overview

For Travis builds running multiple jobs (to test with multiple Node versions and/or OSs), travis-deploy-once run some code only once, after all other jobs have completed successfully.

travis-deploy-once is usually used in the after_success step. But if you want your build to break in case the travis-deploy-once script returns an error, you can set it in the script or before_script step (see Travis Build Lifecycle).

Your code will run only on the job identified as the build leader, which is determined as follow, by order of priority:

  • The job with the ID defined in the -b, --buildLeaderId CLI options or the buildLeaderId API option or BUILD_LEADER_ID environment variable.
  • The job configured with the latest Node version (node_js: node).
  • The job configured with the lts Node version (node_js: lts/*).
  • The job with the highest node version
  • The job with the highest job number if none of the jobs specify a node version (see #42)

Note: If multiple jobs match, the one with the highest job ID (which corresponds to the last one defined in .travis.yml) will be identified as the build leader.

CLI

Usage: travis-deploy-once.js [script]

CLI usage with script argument

Run the script passed in the first argument only if the current job is the build leader and all other jobs are successful and return with the exit code of the script. Return with exit code 0 otherwise.

In .travis.yml:

language: node_js
node_js:
  - 8
  - 6
  - 4
os:
  - osx
  - linux
after_success:
  - npm install -g travis-deploy-once
  - travis-deploy-once "deploy-script --script-arg script-arg-value"

The script deploy-script will be called only for the node 8 job running on linux. It will be passed the arguments --script-arg script-arg-value.

CLI usage without script argument

Return with exit code 0 if the current job is the build leader and all other jobs are successful. Return with exit code 1 otherwise.

In .travis.yml:

language: node_js
node_js:
  - 8
  - 6
  - 4
os:
  - osx
  - linux
after_success:
  - npm install -g travis-deploy-once
  - travis-deploy-once && deploy-script --script-arg script-arg-value

The script deploy-script will be called only for the node 8 job running on linux. It will be passed the arguments --script-arg script-arg-value.

CLI options

-t, --githubToken

Type: String Default: GH_TOKEN or GITHUB_TOKEN environment variable

GitHub OAuth token.

-b, --buildLeaderId

Type: Number Default: BUILD_LEADER_ID environment variable

Define which Travis job will run the script (build leader). If not defined the build leader will be the Travis job running on the highest Node version.

-p, --pro

Type: Boolean Default: false

true to use Travis Pro, false to use Travis for Open Source.

-u, --travis-url

Type: String Default: TRAVIS_URL environment variable

Travis Enterprise URL. If defined, the -p, --pro option will be ignored.

Note: This is the URL of the API endpoint, for example https://travis.example.com/api.

-h, --help

Type: Boolean

Show help.

-v, --version

Type: Boolean

Show version number.

API

API usage

npm install --save travis-deploy-once

In the module my-module:

const deployOnce = require('travis-deploy-once');

try {
  const result = await deployOnce({travisOpts: {pro: true}, githubToken: 'xxxxxx', buildLeaderId: 1});

  if (result === true) deployMyThing();
  if (result === false) console.log('Some job(s) failed');
  if (result === null) console.log('Did not run as the build leader');
} catch (err) {
  // something went wrong, and err will tell you what
}

In .travis.yml:

language: node_js
node_js:
  - 8
  - 6
  - 4
os:
  - osx
  - linux
after_success:
  - npm run my-module

The script my-module with be called for each node version on both OSs and deployMyThing will be called only for the node 8 job running on linux.

Function deployOnce([options])

Returns a Promise that resolves to:

  • true if the current Travis job is the build leader, the current script phase is successful and all other job have completed successfully. => Your code can safely run.
  • false if at least one Travis job failed. => Your code should not run.
  • null if the current Travis job is not the build leader. => Your code should not run, and will be executed on the build leader.

Throws an Error if:

  • It doesn't run on Travis.
  • The Github authentication token is missing.
  • The Github authentication token is not authorized with Travis.

options

Type: Object

githubToken

Type: String Default: process.env.GH_TOKEN or process.env.GITHUB_TOKEN

GitHub OAuth token.

buildLeaderId

Type: Number Default: process.env.BUILD_LEADER_ID

Define which Travis job will run the script (build leader). If not defined the build leader will be the Travis job running on the highest Node version.

travisOpts

Type: Object

pro

Type: Boolean Default: false

true to use Travis Pro, false to use Travis for Open Source.

enterprise

Type: String Default: process.env.TRAVIS_URL

Travis Enterprise URL. If defined, the pro option will be ignored.

Note: This is the URL of the API endpoint, for example https://travis.example.com/api.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].