@@ -31470,35 +31470,29 @@ function runPushAlert(args) {
31470
31470
if (!args.slackEndpoint) {
31471
31471
throw new Error('Slack notification endpoint undefined');
31472
31472
}
31473
- // this is requried for List branches or pull requests for a commit
31474
- // detail: https://developer.github.com/v3/previews/#list-branches-or-pull-requests-for-a-commit
31475
31473
const client = github.getOctokit(args.repoToken);
31476
- //const commits = github.context.payload.commits
31477
31474
if (!process.env.GITHUB_SHA) {
31478
31475
return;
31479
31476
}
31480
- const commits = [process.env.GITHUB_SHA];
31481
- for (const commit of commits) {
31482
- const reviewed = yield verifyCommitReview(client, commit);
31483
- if (reviewed === false) {
31484
- //notify channel
31485
- var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`;
31486
- const req = request.post(args.slackEndpoint, {
31487
- json: {
31488
- text: `Unreviewed Commit from ${github_commit_url}`,
31489
- channel: `#${args.alertChannel}`
31490
- }
31491
- }, (error, res, body) => {
31492
- if (error) {
31493
- console.error(error);
31494
- return;
31495
- }
31496
- console.log(`statusCode: ${res.statusCode}`);
31497
- console.log(body);
31498
- });
31499
- }
31477
+ const commit = process.env.GITHUB_SHA;
31478
+ const reviewed = yield verifyCommitReview(client, commit);
31479
+ if (reviewed === false) {
31480
+ //notify channel
31481
+ var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`;
31482
+ const req = request.post(args.slackEndpoint, {
31483
+ json: {
31484
+ text: `Unreviewed Commit from ${github_commit_url}`,
31485
+ channel: `#${args.alertChannel}`
31486
+ }
31487
+ }, (error, res, body) => {
31488
+ if (error) {
31489
+ console.error(error);
31490
+ return;
31491
+ }
31492
+ console.log(`statusCode: ${res.statusCode}`);
31493
+ console.log(body);
31494
+ });
31500
31495
}
31501
- ;
31502
31496
}
31503
31497
catch (error) {
31504
31498
core.error(error);
@@ -31515,6 +31509,7 @@ function verifyCommitReview(client, commit_sha) {
31515
31509
const pull_requests = yield client.request("GET /repos/:owner/:repo/commits/:commit_sha/pulls", {
31516
31510
mediaType: {
31517
31511
//the function is only available for preview on github
31512
+ // detail: https://developer.github.com/v3/previews/#list-branches-or-pull-requests-for-a-commit
31518
31513
previews: ["groot"]
31519
31514
},
31520
31515
owner: github.context.repo.owner,
0 commit comments