Compare commits
1 Commits
d9fba56335
...
ec14a479c8
| Author | SHA1 | Date | |
|---|---|---|---|
| ec14a479c8 |
@@ -1,3 +1,4 @@
|
||||
import dotenv from 'dotenv';
|
||||
import createRepo from './lib/create_repo.mjs';
|
||||
import getComments from './lib/get_comments.mjs';
|
||||
import getPull from './lib/get_pull.mjs';
|
||||
@@ -5,17 +6,20 @@ import getCommits from './lib/get_commits.mjs';
|
||||
import getCommitStatus from './lib/get_commit_status.mjs';
|
||||
import History from './lib/history.mjs';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export default async function() {
|
||||
// parse repo name from cli and create repo instance
|
||||
const repo = createRepo(process.argv.splice(2)[0]);
|
||||
const { COMMENT_BODY_REGEXP, COMMENT_BODY_REGEXP_FLAGS, COMMENT_ACTOR } = process.env;
|
||||
|
||||
// load the history module
|
||||
const history = new History();
|
||||
|
||||
// fetch comment info from event stream, filter for only new comments
|
||||
const comments = (await getComments(repo, {
|
||||
body: /build failed/i,
|
||||
actor: 'elasticmachine',
|
||||
body: new RegExp(COMMENT_BODY_REGEXP, COMMENT_BODY_REGEXP_FLAGS),
|
||||
actor: COMMENT_ACTOR,
|
||||
})).filter(comment => !history.get(comment.id));
|
||||
|
||||
// read pull data, filter out any closed pulls
|
||||
|
||||
@@ -8,8 +8,11 @@ function usageError() {
|
||||
|
||||
export default function(repo) {
|
||||
if (typeof repo !== 'string' || repo.length === 0) usageError();
|
||||
const settings = {
|
||||
token: process.env.GITHUB_ACCESS_TOKEN,
|
||||
};
|
||||
|
||||
const octo = new Octokat();
|
||||
const octo = new Octokat(settings);
|
||||
const [owner, name] = repo.split('/');
|
||||
|
||||
if (!owner || !name) usageError();
|
||||
|
||||
Reference in New Issue
Block a user