Skip to content

Commit

Permalink
Support community PR builds
Browse files Browse the repository at this point in the history
## Changes:

- Fix PR builds on Travis that do not have access to secure env vars
  • Loading branch information
kamranayub authored and eonarheim committed Apr 27, 2017
1 parent 316daa5 commit a6f90ef
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const request = require('sync-request');
const appveyorBuild = process.env.APPVEYOR_BUILD_NUMBER || '';
const travisBuild = process.env.TRAVIS_BUILD_NUMBER || '';
const commit = process.env.TRAVIS_COMMIT || '';
const travisPr = process.env.TRAVIS_PULL_REQUEST || 'false';

// ignore local builds
if (!appveyorBuild && !travisBuild) {
Expand All @@ -10,6 +11,13 @@ if (!appveyorBuild && !travisBuild) {
return;
}

// ignore community PR builds
if (!process.env.GH_TOKEN && travisPr !== 'false') {
console.info('Travis PR build, using version', 'pr-' + travisPr);
module.exports = 'pr-' + travisPr;
return;
}

// fail build if no GH_TOKEN present
if (!process.env.GH_TOKEN) {
throw Error('Missing environment variable GH_TOKEN');
Expand Down Expand Up @@ -42,4 +50,4 @@ if (appveyorBuild) {
} else {
console.info('Using Travis build as version', travisVersion);
module.exports = travisVersion;
}
}

0 comments on commit a6f90ef

Please sign in to comment.