Skip to content

Commit

Permalink
Merge pull request #11 from Expensify/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
tugbadogan authored Apr 8, 2021
2 parents 28b7fef + 0aef92d commit 743fce8
Show file tree
Hide file tree
Showing 65 changed files with 32,642 additions and 12,158 deletions.
15 changes: 15 additions & 0 deletions .github/actions/checkDeployBlockers/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Check Deploy blockers'
description: 'Check a recently closed `ProductionDeployCash` issue for unchecked boxes or a missing `:shipit:` comment'
inputs:
GITHUB_TOKEN:
description: Auth token for Expensify.cash Github; necessary for accessing Octokit.
required: true
ISSUE_NUMBER:
description: The number of the recently closed issue
required: true
outputs:
HAS_DEPLOY_BLOCKERS:
description: A true/false indicating whether or not a deploy blocker was found.
runs:
using: 'node12'
main: 'index.js'
65 changes: 65 additions & 0 deletions .github/actions/checkDeployBlockers/checkDeployBlockers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const _ = require('underscore');
const core = require('@actions/core');
const github = require('@actions/github');
const {GITHUB_OWNER, EXPENSIFY_CASH_REPO} = require('../../libs/GithubUtils');

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

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

return octokit.issues.get({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
})
.then(({data}) => {
console.log('Checking for unverified PRs or unresolved deploy blockers', data);
const pattern = /-\s\[\s]/g;
const matches = pattern.exec(data.body);
if (matches !== null) {
console.log('An unverified PR or unresolved deploy blocker was found.');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
}

return octokit.issues.listComments({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
});
})
.then((issues) => {
if (_.isUndefined(issues)) {
return;
}

if (_.isEmpty(issues.data)) {
console.log('No comments found on issue');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
}

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))) {
console.log('The last comment on the issue was not :shipit');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
} else {
console.log('Everything looks good, there are no deploy blockers!');
core.setOutput('HAS_DEPLOY_BLOCKERS', false);
}
})
.catch((error) => {
console.error('A problem occurred while trying to communicate with the GitHub API', error);
core.setFailed(error);
});
};

if (require.main === module) {
run();
}

module.exports = run;
Loading

0 comments on commit 743fce8

Please sign in to comment.