Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #54 from tinyspeck/rls-1.1.0
Browse files Browse the repository at this point in the history
1.1.0 release
  • Loading branch information
shiqi authored Jul 6, 2020
2 parents 68456db + a4e1921 commit 495581f
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31470,35 +31470,29 @@ function runPushAlert(args) {
if (!args.slackEndpoint) {
throw new Error('Slack notification endpoint undefined');
}
// this is requried for List branches or pull requests for a commit
// detail: https://developer.github.com/v3/previews/#list-branches-or-pull-requests-for-a-commit
const client = github.getOctokit(args.repoToken);
//const commits = github.context.payload.commits
if (!process.env.GITHUB_SHA) {
return;
}
const commits = [process.env.GITHUB_SHA];
for (const commit of commits) {
const reviewed = yield verifyCommitReview(client, commit);
if (reviewed === false) {
//notify channel
var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`;
const req = request.post(args.slackEndpoint, {
json: {
text: `Unreviewed Commit from ${github_commit_url}`,
channel: `#${args.alertChannel}`
}
}, (error, res, body) => {
if (error) {
console.error(error);
return;
}
console.log(`statusCode: ${res.statusCode}`);
console.log(body);
});
}
const commit = process.env.GITHUB_SHA;
const reviewed = yield verifyCommitReview(client, commit);
if (reviewed === false) {
//notify channel
var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`;
const req = request.post(args.slackEndpoint, {
json: {
text: `Unreviewed Commit from ${github_commit_url}`,
channel: `#${args.alertChannel}`
}
}, (error, res, body) => {
if (error) {
console.error(error);
return;
}
console.log(`statusCode: ${res.statusCode}`);
console.log(body);
});
}
;
}
catch (error) {
core.error(error);
Expand All @@ -31515,6 +31509,7 @@ function verifyCommitReview(client, commit_sha) {
const pull_requests = yield client.request("GET /repos/:owner/:repo/commits/:commit_sha/pulls", {
mediaType: {
//the function is only available for preview on github
// detail: https://developer.github.com/v3/previews/#list-branches-or-pull-requests-for-a-commit
previews: ["groot"]
},
owner: github.context.repo.owner,
Expand Down

0 comments on commit 495581f

Please sign in to comment.