blob: 81069c8a130042eadf9ff46041b9d7aeb70c088c [file] [log] [blame]
Gabriel Peal69ab3f12017-12-11 16:35:38 -05001#! /usr/bin/env node
2
3if (!process.env.TRAVIS_REPO_SLUG) {
4 process.exit(0);
5}
6
7const https = require('https');
8
Gabriel Peal83c6f1e2018-11-13 08:28:22 -08009const 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 Peal69ab3f12017-12-11 16:35:38 -050010
11const 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
23const 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})
34req.write(postData);
35req.end();