Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"github>probot/.github"
]
}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:10

WORKDIR /app
COPY package* ./
RUN npm install --production
COPY . .

ENTRYPOINT ["/app/node_modules/.bin/probot", "receive"]
CMD ["/app/src/index.js"]
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
"debug": "^2.6.3",
"fuse.js": "^2.6.2",
"mustache": "^2.3.0",
"probot": "~0.3.0"
"probot": "^7.3.0-rc2"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint-config-probot": "^0.1.0",
"mocha": "^3.2.0",
"node-fetch": "^1.6.3",
"nodemon": "^1.18.4",
"sinon": "^2.1.0",
"smee-client": "^1.0.2",
"xo": "^0.19.0"
},
"engines": {
Expand Down
16 changes: 9 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
const fs = require('fs');
const path = require('path');
const debug = require('debug')('index');
const mustache = require('mustache');

const search = require('./search');

const defaultTemplate = fs.readFileSync(path.resolve(__dirname, 'template.md'), { encoding: 'utf-8' });

module.exports = robot => {
robot.on('issues.opened', async (event, context) => {
const github = await robot.auth(event.payload.installation.id);
debug('issue opened');
robot.on('issues.opened', async context => {
const github = context.github;
context.log('issue opened');

// Get all issues that aren't the new issue
const allIssues = await github.paginate(github.issues.getForRepo(context.repo()), issues => issues);
const req = github.issues.getForRepo(context.repo({state: 'all'}))
const allIssues = await github.paginate(req, res => res.data);

context.log(`Checking ${allIssues.length} issues`);

const results = search(allIssues, context.issue().number);

debug(`found ${results.length} potential duplicates`);
context.log(`found ${results.length} potential duplicates`);

if (results.length > 0) {
let template;
Expand All @@ -33,7 +35,7 @@ module.exports = robot => {
}

const commentBody = mustache.render(template, {
payload: event.payload,
payload: context.payload,
issues: results.slice(0, 3)
});

Expand Down
Loading