Skip to content

Commit

Permalink
Recompile GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
deetergp committed Apr 7, 2021
1 parent d4fb326 commit 4d6576d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
33 changes: 15 additions & 18 deletions .github/actions/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ module.exports =
/***/ 7978:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const _ = __nccwpck_require__(4987);
const core = __nccwpck_require__(2186);
const github = __nccwpck_require__(5438);
const {GITHUB_OWNER, EXPENSIFY_CASH_REPO} = __nccwpck_require__(7999);

const run = function () {
const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
const issueNumber = Number(core.getInput('ISSUE_NUMBER', {required: true}));
let hasDeployBlockers = false;

console.log(`Fetching issue number ${issueNumber}`);

Expand All @@ -28,10 +28,10 @@ const run = function () {
console.log('Checking for unverified PRs or unresolved deploy blockers', data);
const pattern = /-\s\[\s]/g;
const matches = pattern.exec(data.body);
hasDeployBlockers = matches !== null;
if (hasDeployBlockers) {
if (matches !== null) {
console.log('An unverified PR or unresolved deploy blocker was found.');
return {};
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
}

return octokit.issues.listComments({
Expand All @@ -40,21 +40,18 @@ const run = function () {
issue_number: issueNumber,
});
})
.then(({data}) => {
if (!data) {
return;
}

console.log('Verifying that the last comment is :shipit:');
const lastComment = data[data.length - 1];
const shipItRegex = /^:shipit:/g;
hasDeployBlockers = shipItRegex.exec(lastComment.body) === null;
if (hasDeployBlockers) {
console.log('The last comment on the issue was not :shipit:');
.then((issues) => {
if (!_.isUndefined(issues)) {
console.log('Verifying that the last comment is :shipit:');
const lastComment = issues.data[issues.data.length - 1];
const shipItRegex = /^:shipit:/g;
if (_.isNull(shipItRegex.exec(lastComment.body))) {
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
console.log('The last comment on the issue was not :shipit');
return;
}
}
})
.then(() => {
core.setOutput('HAS_DEPLOY_BLOCKERS', hasDeployBlockers);
core.setOutput('HAS_DEPLOY_BLOCKERS', false);
})
.catch((error) => {
console.error('A problem occurred while trying to communicate with the GitHub API', error);
Expand Down
11 changes: 6 additions & 5 deletions .github/actions/reopenIssueWithComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,34 @@ const {GITHUB_OWNER, EXPENSIFY_CASH_REPO} = __nccwpck_require__(7999);

const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
const issueNumber = core.getInput('ISSUE_NUMBER', {required: true});
const comment = core.getInput('COMMENT', {required: true});

function reopenIssueWithComment() {
console.log(`Reopening issue # ${issueNumber}`);
console.log(`Reopening issue #${issueNumber}`);
octokit.issues.update({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
state: 'open',
})
.then(() => {
console.log(`Commenting on issue # ${issueNumber}`);
console.log(`Commenting on issue #${issueNumber}`);
octokit.issues.createComment({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
body: core.getInput('COMMENT', {required: true}),
body: comment,
});
});
}

reopenIssueWithComment()
.then(() => {
console.log(`Issue # ${issueNumber} successfully reopened and commented.`);
console.log(`Issue #${issueNumber} successfully reopened and commented: "${comment}"`);
process.exit(0);
})
.catch((err) => {
console.error(`Something went wrong. The issue # ${issueNumber} was not successfully reopened`, err);
console.error(`Something went wrong. The issue #${issueNumber} was not successfully reopened`, err);
core.setFailed(err);
});

Expand Down

0 comments on commit 4d6576d

Please sign in to comment.