Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const _ = require('underscore');
const core = require('@actions/core');
const CONST = require('../../../libs/CONST');
const GithubUtils = require('../../../libs/GithubUtils');
/* eslint-disable @typescript-eslint/naming-convention */
import * as core from '@actions/core';
import CONST from '@github/libs/CONST';
import GithubUtils from '@github/libs/GithubUtils';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

const run = function () {
const run = function (): Promise<void> {
const issueNumber = Number(core.getInput('ISSUE_NUMBER', {required: true}));

console.log(`Fetching issue number ${issueNumber}`);
Expand All @@ -19,7 +20,7 @@ const run = function () {

// Check the issue description to see if there are any unfinished/un-QAed items in the checklist.
const uncheckedBoxRegex = /-\s\[\s]\s/;
if (uncheckedBoxRegex.test(data.body)) {
if (uncheckedBoxRegex.test(data.body ?? '')) {
console.log('An unverified PR or unresolved deploy blocker was found.');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
Expand All @@ -37,12 +38,12 @@ const run = function () {

// If comments is undefined that means we found an unchecked QA item in the
// issue description, so there's nothing more to do but return early.
if (_.isUndefined(comments)) {
if (comments === undefined) {
return;
}

// If there are no comments, then we have not yet gotten the :shipit: seal of approval.
if (_.isEmpty(comments.data)) {
if (isEmptyObject(comments.data)) {
console.log('No comments found on issue');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
Expand All @@ -51,7 +52,7 @@ const run = function () {
console.log('Verifying that the last comment is the :shipit: seal of approval');
const lastComment = comments.data.pop();
const shipItRegex = /^:shipit:/g;
if (_.isNull(shipItRegex.exec(lastComment.body))) {
if (!shipItRegex.exec(lastComment?.body ?? '')) {
console.log('The last comment on the issue was not :shipit');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
} else {
Expand All @@ -69,4 +70,4 @@ if (require.main === module) {
run();
}

module.exports = run;
export default run;
Loading