2018-11-08 02:49:16 -08:00
|
|
|
require('dotenv').config();
|
2018-11-20 15:31:28 -08:00
|
|
|
|
|
|
|
const { owner, repo, octokitConfig, octokitAuth } = require('../constants');
|
2018-11-08 02:49:16 -08:00
|
|
|
const octokit = require('@octokit/rest')(octokitConfig);
|
2018-11-09 11:29:22 -08:00
|
|
|
|
2018-11-08 02:49:16 -08:00
|
|
|
octokit.authenticate(octokitAuth);
|
|
|
|
|
2018-11-20 15:31:28 -08:00
|
|
|
/* closes and reopens an open PR with applicable comment */
|
2018-11-08 02:49:16 -08:00
|
|
|
const prOpenClose = async (number) => {
|
|
|
|
const result = await octokit.pullRequests.update({ owner, repo , number, state: 'closed', base: 'master' })
|
2018-11-06 23:04:43 -08:00
|
|
|
.then(() => {
|
2018-11-08 02:49:16 -08:00
|
|
|
return octokit.pullRequests.update({ owner, repo , number, state: 'open', base: 'master' })
|
2018-11-06 23:04:43 -08:00
|
|
|
})
|
|
|
|
.then(() => {
|
2018-11-09 11:29:22 -08:00
|
|
|
addComment(number, 'Closed and Reopened this PR to attempt to resolve a specific Travis build failure.');
|
2018-11-06 23:04:43 -08:00
|
|
|
})
|
2018-11-08 02:49:16 -08:00
|
|
|
.catch((err) => {
|
|
|
|
console.log(err)
|
2018-11-06 23:04:43 -08:00
|
|
|
})
|
|
|
|
};
|
|
|
|
|
2018-11-11 23:52:00 -08:00
|
|
|
module.exports = prOpenClose;
|