2019-10-01 00:07:07 +02:00
|
|
|
const https = require('https');
|
|
|
|
|
2019-11-04 11:08:17 +01:00
|
|
|
const auth = 'Basic ' + Buffer.from(process.env.GITHUB).toString('base64');
|
2019-10-01 00:07:07 +02:00
|
|
|
|
2021-08-07 10:54:57 +02:00
|
|
|
const gitCommand = "git log -n 1 --pretty=%d HEAD | awk '{print $2}' | sed 's/origin\\///' | sed 's/)//'";
|
|
|
|
const branch = require('child_process').execSync(gitCommand).toString().trim();
|
2019-10-01 00:36:37 +02:00
|
|
|
|
2020-05-25 13:16:41 +02:00
|
|
|
if (branch === 'master') process.exit();
|
|
|
|
|
2019-10-01 00:07:07 +02:00
|
|
|
const req = https.request(
|
|
|
|
{
|
|
|
|
hostname: 'api.github.com',
|
|
|
|
port: 443,
|
|
|
|
path: '/repos/BlueWallet/BlueWallet/pulls',
|
|
|
|
method: 'GET',
|
|
|
|
headers: { 'User-Agent': 'BlueWallet bot', Authorization: auth },
|
|
|
|
},
|
|
|
|
resp => {
|
|
|
|
let data = '';
|
|
|
|
|
|
|
|
resp.on('data', chunk => {
|
|
|
|
data += chunk;
|
|
|
|
});
|
|
|
|
|
|
|
|
resp.on('end', () => {
|
|
|
|
try {
|
|
|
|
const prs = JSON.parse(data);
|
2021-08-07 10:54:57 +02:00
|
|
|
for (const pr of prs) {
|
2019-10-01 00:36:37 +02:00
|
|
|
if (branch === pr.head.ref) {
|
2019-10-01 00:07:07 +02:00
|
|
|
console.log(pr.number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
console.log('got json: ', data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
req.on('error', e => {
|
|
|
|
console.error(e);
|
|
|
|
});
|
|
|
|
|
|
|
|
req.end();
|