Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reopenIssueWithComment GitHub Action #2163

Merged
merged 35 commits into from
Apr 8, 2021
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dc4e86d
Added the basic action
deetergp Mar 30, 2021
4ece418
Modularize how GithubUtils gets used
deetergp Mar 31, 2021
9b83394
Add a new job w/ steps to finisReleaseCycle flow
deetergp Mar 31, 2021
6076b0c
Pass params to reopenIssueWihtComments action
deetergp Mar 31, 2021
5037b7d
Pass params to checkDeployBlockers action
deetergp Apr 1, 2021
29cb636
Add checkDeployBlockers action
deetergp Apr 1, 2021
28aa402
Add compiled index files for new actions
deetergp Apr 1, 2021
224a413
Make reopenIssueWithComment asynchronous
deetergp Apr 1, 2021
2b512c4
Fix formatting to make eslint happy
deetergp Apr 2, 2021
922dedc
Get rid of async/await in code checkDeployBlockers
deetergp Apr 2, 2021
c5ff0e7
Update compiled index files
deetergp Apr 2, 2021
08a400e
Recompile index files after pulling master
deetergp Apr 2, 2021
f8ff317
Add a reminder to pull master to verifyActions
deetergp Apr 2, 2021
2349eb9
Encapsulate action in a run function
deetergp Apr 5, 2021
536e677
Compiled index.js
deetergp Apr 5, 2021
3445792
Added tests for checkbox checking
deetergp Apr 5, 2021
2d985b4
Check last comment for :shipit:
deetergp Apr 5, 2021
d7d8fb6
Test for `:shipit:` in last comment
deetergp Apr 6, 2021
048844e
Recompile index
deetergp Apr 6, 2021
b40e801
Making ESLint happy
deetergp Apr 6, 2021
4d505f2
Fixed typo in filename
deetergp Apr 6, 2021
1ddcbf1
Destructuring returned data; add logging comments
deetergp Apr 6, 2021
07f3a07
Remove unnecessary rest from octokit commands
deetergp Apr 6, 2021
d07e48a
Fix comments in YAML for checkDeployBlockers
deetergp Apr 6, 2021
291eaaf
Add more logging; catch block; remove nested then
deetergp Apr 6, 2021
bcf3c98
Improved logging in reopenIssueWithComments
deetergp Apr 6, 2021
c3cd058
Fixed typo in workflow yaml
deetergp Apr 6, 2021
513b327
Leave baseIssue alone in test
deetergp Apr 6, 2021
41d17be
Recompile GH Actions
deetergp Apr 6, 2021
958c077
Remove hasDeployBlockers global; improve logic path
deetergp Apr 7, 2021
ce1b0e8
Add comment to logs
deetergp Apr 7, 2021
d4fb326
Fixed comment formatting
deetergp Apr 7, 2021
4d6576d
Recompile GH Actions
deetergp Apr 7, 2021
f0ccf58
Return early if no issues found; add test for case
deetergp Apr 7, 2021
65b3609
Recompile GH Actions
deetergp Apr 7, 2021
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
33 changes: 15 additions & 18 deletions .github/actions/checkDeployBlockers/checkDeployBlockers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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}));
let hasDeployBlockers = false;

roryabraham marked this conversation as resolved.
Show resolved Hide resolved
console.log(`Fetching issue number ${issueNumber}`);

Expand All @@ -18,10 +18,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;
}

roryabraham marked this conversation as resolved.
Show resolved Hide resolved
return octokit.issues.listComments({
Expand All @@ -30,21 +30,18 @@ const run = function () {
issue_number: issueNumber,
});
})
.then(({data}) => {
if (!data) {
return;
.then((issues) => {
if (!_.isUndefined(issues)) {
deetergp marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}

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(() => {
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