-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env node | ||
|
||
const { | ||
exec | ||
} = require('child_process'); | ||
|
||
const travisPullRequest = process.env.TRAVIS_PULL_REQUEST; | ||
const nowToken = process.env.NOW_TOKEN; | ||
const isTravis = process.env.TRAVIS; | ||
|
||
if (!isTravis || !travisPullRequest) { | ||
console.info('not running on a travis pull request job. silently quitting...'); | ||
process.exit(0); | ||
} | ||
|
||
if (!nowToken) { | ||
console.error('required environment variable NOW_TOKEN is not set'); | ||
throw new Error('required environment variable NOW_TOKEN is not set'); | ||
} | ||
|
||
exec(`now alias --token=${nowToken} $(now ./test-results --no-clipboard --token=${nowToken} --public) achievibit-pr-${ travisPullRequest }`, | ||
async (err, stdout, stderr) => { | ||
if (err) { | ||
console.error(err); | ||
// node couldn't execute the command | ||
return; | ||
} | ||
|
||
const Octokit = require("@octokit/rest"); | ||
const auth = process.env.GH_TOKEN; | ||
const octokit = new Octokit({ auth }); | ||
|
||
const prSlug = process.env.TRAVIS_PULL_REQUEST_SLUG; | ||
|
||
const splitted = prSlug.split('\/'); | ||
|
||
const testReportUrl = `https://achievibit-pr-${ travisPullRequest }.now.sh` | ||
|
||
const comment = { | ||
repo: splitted[1], | ||
owner: splitted[0], | ||
issue_number: travisPullRequest, | ||
body: 'Test report is available on ' + testReportUrl | ||
}; | ||
|
||
const response = await octokit.issues.createComment(comment); | ||
|
||
// the *entire* stdout and stderr (buffered) | ||
console.log(`stdout: ${stdout}`); | ||
console.log(`stderr: ${stderr}`); | ||
console.log(response); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters