Skip to content

Commit

Permalink
chores: do not continue if there is no RP
Browse files Browse the repository at this point in the history
  • Loading branch information
UcheSylvester committed Nov 7, 2023
1 parent e7db003 commit 329117b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 7 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ const helpers_1 = __nccwpck_require__(863);
const run = async () => {
var _a, _b, _c;
try {
const baseSha = ((_a = github_1.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base.sha) || constants_1.BASE_SHA;
const headSha = ((_b = github_1.context.payload.pull_request) === null || _b === void 0 ? void 0 : _b.head.sha) || constants_1.HEAD_SHA;
// no need to proceed if there is no PR
if (!github_1.context.payload.pull_request) {
(0, core_1.warning)('No pull request found!');
return;
}
const baseSha = (_a = github_1.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base.sha;
const headSha = (_b = github_1.context.payload.pull_request) === null || _b === void 0 ? void 0 : _b.head.sha;
const creator = (_c = github_1.context.payload.pull_request) === null || _c === void 0 ? void 0 : _c.user.login;
const maxReviewers = (0, core_1.getInput)('max-reviewers');
const token = (0, core_1.getInput)('github-token');
Expand Down
12 changes: 9 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { context, getOctokit } from '@actions/github';
import { getInput, info, setFailed, warning } from '@actions/core';
import { BASE_SHA, DEFAULT_MAX_REVIEWERS, HEAD_SHA } from './constants';
import { DEFAULT_MAX_REVIEWERS } from './constants';
import {
getChangedFiles,
getReviewersEmails,
Expand All @@ -11,8 +11,14 @@ import {

export const run = async () => {
try {
const baseSha = context.payload.pull_request?.base.sha || BASE_SHA;
const headSha = context.payload.pull_request?.head.sha || HEAD_SHA;
// no need to proceed if there is no PR
if (!context.payload.pull_request) {
warning('No pull request found!');
return;
}

const baseSha = context.payload.pull_request?.base.sha;
const headSha = context.payload.pull_request?.head.sha;
const creator = context.payload.pull_request?.user.login;

const maxReviewers = getInput('max-reviewers');
Expand Down

0 comments on commit 329117b

Please sign in to comment.