feature: added addComment feature

This commit is contained in:
Randell Dawson
2018-11-09 11:26:59 -08:00
committed by mrugesh mohapatra
parent abd2d5cafd
commit 6d7d5129e0

21
addComment.js Normal file
View File

@ -0,0 +1,21 @@
require('dotenv').config();
const { owner, repo } = require('./constants');
const { octokitConfig, octokitAuth } = require('./octokitConfig');
const octokit = require('@octokit/rest')(octokitConfig);
octokit.authenticate(octokitAuth);
const addComment = (number, comment) => {
setTimeout(async () => {
octokit.issues.createComment({ owner, repo, number, body: comment })
.then(() => {
console.log(`PR #${number} successfully added a comment\n`);
})
.catch((err) => {
console.log(`PR #${number} had an error when trying to add a comment\n`);
console.log(err)
})
}, 1000); // wait one second to comment for API rate limiting compliance
};
exports.addComment = addComment;