Gabriel Peal | 69ab3f1 | 2017-12-11 16:35:38 -0500 | [diff] [blame] | 1 | #! /usr/bin/env node |
| 2 | |
| 3 | if (!process.env.TRAVIS_REPO_SLUG) { |
| 4 | process.exit(0); |
| 5 | } |
| 6 | |
| 7 | const https = require('https'); |
| 8 | |
Gabriel Peal | 83c6f1e | 2018-11-13 08:28:22 -0800 | [diff] [blame] | 9 | const postData = `{\"body\": \"**Snapshot Tests**\\nReport: https://happo.io/a/27/report/${process.env.GIT_SHA}-android26\\nDiff: https://happo.io/a/27/compare/master-android26/${process.env.GIT_SHA}-android26\"}` |
Gabriel Peal | 69ab3f1 | 2017-12-11 16:35:38 -0500 | [diff] [blame] | 10 | |
| 11 | const options = { |
| 12 | hostname: 'api.github.com', |
| 13 | path: `/repos/${process.env.TRAVIS_REPO_SLUG}/issues/${process.env.TRAVIS_PULL_REQUEST}/comments`, |
| 14 | port: 443, |
| 15 | method: 'POST', |
| 16 | headers: { |
| 17 | Authorization: `token ${process.env.GITHUB_ACCESS_TOKEN}`, |
| 18 | 'Content-Length': postData.length, |
| 19 | 'User-Agent': 'Travis/1.6.8 (Mac OS X 10.9.2 like Darwin; Ruby 2.1.1; RubyGems 2.0.14) Faraday/0.8.9 Typhoeus/0.6.7.' |
| 20 | } |
| 21 | }; |
| 22 | |
| 23 | const req = https.request(options, res => { |
| 24 | console.log('statusCode:', res.statusCode); |
| 25 | console.log('headers:', res.headers); |
| 26 | |
| 27 | res.on('data', d => { |
| 28 | process.stdout.write(d); |
| 29 | }); |
| 30 | res.on('error', e => { |
| 31 | process.stderr.write(e); |
| 32 | }) |
| 33 | }) |
| 34 | req.write(postData); |
| 35 | req.end(); |