Skip to content

Commit

Permalink
Rebuild GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Mar 12, 2021
1 parent 523a3ea commit effb7c3
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions .github/actions/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ class GithubUtils {
})
.then(({data}) => {
if (!data.length) {
throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`);
const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`);
error.code = 404;
throw error;
}

if (data.length > 1) {
throw new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`);
const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`);
error.code = 500;
throw error;
}

return this.getStagingDeployCashData(data[0]);
Expand All @@ -81,10 +85,8 @@ class GithubUtils {
/**
* Takes in a GitHub issue object and returns the data we want.
*
* @private
*
* @param {Object} issue
* @returns {Promise}
* @returns {Object}
*/
getStagingDeployCashData(issue) {
try {
Expand Down Expand Up @@ -150,7 +152,11 @@ class GithubUtils {
* @returns {Array<Object>} - [{URL: String, number: Number, isResolved: Boolean}]
*/
getStagingDeployCashDeployBlockers(issue) {
const deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r\n((?:.*\r\n)+)/)[1];
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r\n((?:.*\r\n)+)/) || [];
if (deployBlockerSection.length !== 2) {
return [];
}
deployBlockerSection = deployBlockerSection[1];
const unresolvedDeployBlockers = _.map(
[...deployBlockerSection.matchAll(new RegExp(`- \\[ ] (${ISSUE_OR_PULL_REQUEST_REGEX.source})`, 'g'))],
match => ({
Expand Down Expand Up @@ -251,8 +257,8 @@ class GithubUtils {
.then(body => this.octokit.issues.create({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
labels: STAGING_DEPLOY_CASH_LABEL,
assignee: APPLAUSE_BOT,
labels: [STAGING_DEPLOY_CASH_LABEL],
assignees: [APPLAUSE_BOT],
title,
body,
}));
Expand Down Expand Up @@ -329,7 +335,7 @@ class GithubUtils {
deployBlockers = [],
resolvedDeployBlockers = [],
) {
return this.generateVersionComparisonURL(`${GITHUB_OWNER}/${EXPENSIFY_CASH_REPO}`, tag, 'BUILD')
return this.generateVersionComparisonURL(`${GITHUB_OWNER}/${EXPENSIFY_CASH_REPO}`, tag, 'PATCH')
.then((comparisonURL) => {
const sortedPRList = _.sortBy(_.unique(PRList), URL => GithubUtils.getPullRequestNumberFromURL(URL));
// eslint-disable-next-line max-len
Expand Down Expand Up @@ -383,6 +389,16 @@ class GithubUtils {
});
}

/**
* Generate the URL of an Expensify.cash pull request given the PR number.
*
* @param {Number} number
* @returns {String}
*/
static getPullRequestURLFromNumber(number) {
return `${EXPENSIFY_CASH_URL}/pull/${number}`;
}

/**
* Parse the pull request number from a URL.
*
Expand Down Expand Up @@ -432,6 +448,7 @@ class GithubUtils {
module.exports = GithubUtils;
module.exports.GITHUB_OWNER = GITHUB_OWNER;
module.exports.EXPENSIFY_CASH_REPO = EXPENSIFY_CASH_REPO;
module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL;


/***/ }),
Expand Down

0 comments on commit effb7c3

Please sign in to comment.