Skip to content

Commit

Permalink
Link pull requests to release
Browse files Browse the repository at this point in the history
Fixes babel#13.
  • Loading branch information
aaronang committed Mar 6, 2017
1 parent 635399d commit fdc7138
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/handlers/release/published.js
@@ -0,0 +1,37 @@
// @flow

import github from '../../github';
import Logger from '../../logger';

const { log } = new Logger('release/published.js');

type ReleasePublishedPayload = {
release: {
body: string;
html_url: string;
},
repository: {
owner: { login: string; };
name: string;
}
};

export default function({ release, repository }: ReleasePublishedPayload) {
const { login: owner } = repository.owner;
const { name: repo } = repository;
const { body, html_url: releaseUrl } = release;

const msg = `Released in ${releaseUrl} :tada:`;

log('Linking pull requests to release', 'verbose');

const regex = /- \[#(\d+)]/g;

let match;

while ((match = regex.exec(body)) !== null) {
const issue = match[1];
log(`Add comment to /repos/${owner}/${repo}/issues/${issue}/comments`, 'verbose');
github.addIssueComment(issue, owner, repo, msg);
}
}

0 comments on commit fdc7138

Please sign in to comment.