-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Expensify/master
Merge
- Loading branch information
Showing
65 changed files
with
32,642 additions
and
12,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
65
.github/actions/checkDeployBlockers/checkDeployBlockers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.