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

[No QA] Create triggerWorkflowAndWait action #2495

Merged
merged 29 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3bfec13
Create triggerWorkflowAndWait action
roryabraham Apr 8, 2021
7b03e0c
temporarily switch repo to public-test-repo for testing
roryabraham Apr 22, 2021
f9b8867
Rebuild GH actions
roryabraham Apr 22, 2021
673568c
Update timer and add process exits
roryabraham Apr 22, 2021
ad134ff
Temporarily use Public-Test-Repo in GithubUtils too
roryabraham Apr 22, 2021
3e33fd6
temporarily hardcode ref in Public-Test-Repo
roryabraham Apr 22, 2021
7d7969e
Make temporary ref a branch, not a commit
roryabraham Apr 22, 2021
98f1392
Rebuild GH actions
roryabraham Apr 22, 2021
e1d3c28
Use ref main
roryabraham Apr 22, 2021
9359021
Log listWorkflowRuns response
roryabraham Apr 22, 2021
a437cbc
Stringify workflow runs
roryabraham Apr 22, 2021
2cb92d7
Use last workflow_run in response instead of first
roryabraham Apr 22, 2021
b8e1686
Fix an oops
roryabraham Apr 22, 2021
045d871
Move error check into then block
roryabraham Apr 22, 2021
cb55342
Catch error in loop
roryabraham Apr 22, 2021
87c4724
Log while loop conditions
roryabraham Apr 22, 2021
27b039b
Return promise from second function in promiseWhile
roryabraham Apr 22, 2021
7fb5606
Remove crazy logs and just log when condition is changed
roryabraham Apr 22, 2021
0e32c5d
Clean up logs
roryabraham Apr 22, 2021
edce3f4
Make log formats more consistent
roryabraham Apr 23, 2021
0397437
Merge branch 'main' into Rory-TriggerWorkflowAndWait
roryabraham Apr 23, 2021
c8c641b
Merge branch 'main' into Rory-TriggerWorkflowAndWait
roryabraham May 7, 2021
9e1a782
Create getJSONInput util
roryabraham May 7, 2021
479e7f0
Revert test changes and rebuild GH actions
roryabraham May 7, 2021
9defb63
Revert missed test changes
roryabraham May 10, 2021
f5b6c20
Update comments to specify milliseconds
roryabraham May 10, 2021
d07dcf4
Add timeout for workflow execution
roryabraham May 11, 2021
490f73e
Merge branch 'main' into Rory-TriggerWorkflowAndWait
roryabraham May 11, 2021
6f3a96f
Rebuild GH Actions
roryabraham May 11, 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
16 changes: 16 additions & 0 deletions .github/actions/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,22 @@ class GithubUtils {
});
}

/**
* Get the most recent workflow run for the given Expensify.cash workflow.
*
* @param {String} workflow
* @returns {Promise}
*/
getLatestWorkflowRunID(workflow) {
console.log(`Fetching Expensify.cash workflow runs for ${workflow}...`);
return this.octokit.actions.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
workflow_id: workflow,
})
.then(response => lodashGet(response, 'data.workflow_runs[0].id'));
}

/**
* Generate the well-formatted body of a production release.
*
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,22 @@ class GithubUtils {
});
}

/**
* Get the most recent workflow run for the given Expensify.cash workflow.
*
* @param {String} workflow
* @returns {Promise}
*/
getLatestWorkflowRunID(workflow) {
console.log(`Fetching Expensify.cash workflow runs for ${workflow}...`);
return this.octokit.actions.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
workflow_id: workflow,
})
.then(response => lodashGet(response, 'data.workflow_runs[0].id'));
}

/**
* Generate the well-formatted body of a production release.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const _ = require('underscore');
const core = require('@actions/core');
const github = require('@actions/github');
const ActionUtils = require('../../libs/ActionUtils');
const GitUtils = require('../../libs/GitUtils');

const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
const inputTag = core.getInput('TAG', {required: true});

const isProductionDeploy = JSON.parse(core.getInput('IS_PRODUCTION_DEPLOY', {required: false}));
const isProductionDeploy = ActionUtils.getJSONInput('IS_PRODUCTION_DEPLOY', {required: false}, false);
const itemToFetch = isProductionDeploy ? 'release' : 'tag';

/**
Expand Down
32 changes: 31 additions & 1 deletion .github/actions/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ module.exports =
const _ = __nccwpck_require__(4987);
const core = __nccwpck_require__(2186);
const github = __nccwpck_require__(5438);
const ActionUtils = __nccwpck_require__(970);
const GitUtils = __nccwpck_require__(669);

const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
const inputTag = core.getInput('TAG', {required: true});

const isProductionDeploy = JSON.parse(core.getInput('IS_PRODUCTION_DEPLOY', {required: false}));
const isProductionDeploy = ActionUtils.getJSONInput('IS_PRODUCTION_DEPLOY', {required: false}, false);
const itemToFetch = isProductionDeploy ? 'release' : 'tag';

/**
Expand Down Expand Up @@ -73,6 +74,35 @@ getTagsOrReleases(isProductionDeploy)
.catch(error => core.setFailed(error));


/***/ }),

/***/ 970:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const core = __nccwpck_require__(2186);

/**
* Safely parse a JSON input to a GitHub Action.
*
* @param {String} name - The name of the input.
* @param {Object} options - Options to pass to core.getInput
* @param {*} [defaultValue] - A default value to provide for the input.
* Not required if the {required: true} option is given in the second arg to this function.
* @returns {any}
*/
function getJSONInput(name, options, defaultValue = undefined) {
const input = core.getInput(name, options);
if (input) {
return JSON.parse(input);
}
return defaultValue;
}

module.exports = {
getJSONInput,
};


/***/ }),

/***/ 669:
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/getReleaseBody/getReleaseBody.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const _ = require('underscore');
const core = require('@actions/core');
const ActionUtils = require('../../libs/ActionUtils');
const GithubUtils = require('../../libs/GithubUtils');

// Parse the stringified JSON array of PR numbers, and cast each from String -> Number
const PRList = _.map(JSON.parse(core.getInput('PR_LIST', {required: true})), Number);
const PRList = _.map(ActionUtils.getJSONInput('PR_LIST', {required: true}), Number);
console.log(`Got PR list: ${PRList}`);

const releaseBody = GithubUtils.getReleaseBody(PRList);
Expand Down
48 changes: 47 additions & 1 deletion .github/actions/getReleaseBody/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ module.exports =

const _ = __nccwpck_require__(4987);
const core = __nccwpck_require__(2186);
const ActionUtils = __nccwpck_require__(970);
const GithubUtils = __nccwpck_require__(7999);

// Parse the stringified JSON array of PR numbers, and cast each from String -> Number
const PRList = _.map(JSON.parse(core.getInput('PR_LIST', {required: true})), Number);
const PRList = _.map(ActionUtils.getJSONInput('PR_LIST', {required: true}), Number);
console.log(`Got PR list: ${PRList}`);

const releaseBody = GithubUtils.getReleaseBody(PRList);
Expand All @@ -22,6 +23,35 @@ console.log(`Generated release body: ${releaseBody}`);
core.setOutput('RELEASE_BODY', releaseBody);


/***/ }),

/***/ 970:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const core = __nccwpck_require__(2186);

/**
* Safely parse a JSON input to a GitHub Action.
*
* @param {String} name - The name of the input.
* @param {Object} options - Options to pass to core.getInput
* @param {*} [defaultValue] - A default value to provide for the input.
* Not required if the {required: true} option is given in the second arg to this function.
* @returns {any}
*/
function getJSONInput(name, options, defaultValue = undefined) {
const input = core.getInput(name, options);
if (input) {
return JSON.parse(input);
}
return defaultValue;
}

module.exports = {
getJSONInput,
};


/***/ }),

/***/ 7999:
Expand Down Expand Up @@ -335,6 +365,22 @@ class GithubUtils {
});
}

/**
* Get the most recent workflow run for the given Expensify.cash workflow.
*
* @param {String} workflow
* @returns {Promise}
*/
getLatestWorkflowRunID(workflow) {
console.log(`Fetching Expensify.cash workflow runs for ${workflow}...`);
return this.octokit.actions.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
workflow_id: workflow,
})
.then(response => lodashGet(response, 'data.workflow_runs[0].id'));
}

/**
* Generate the well-formatted body of a production release.
*
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/isPullRequestMergeable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,22 @@ class GithubUtils {
});
}

/**
* Get the most recent workflow run for the given Expensify.cash workflow.
*
* @param {String} workflow
* @returns {Promise}
*/
getLatestWorkflowRunID(workflow) {
console.log(`Fetching Expensify.cash workflow runs for ${workflow}...`);
return this.octokit.actions.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
workflow_id: workflow,
})
.then(response => lodashGet(response, 'data.workflow_runs[0].id'));
}

/**
* Generate the well-formatted body of a production release.
*
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ class GithubUtils {
});
}

/**
* Get the most recent workflow run for the given Expensify.cash workflow.
*
* @param {String} workflow
* @returns {Promise}
*/
getLatestWorkflowRunID(workflow) {
console.log(`Fetching Expensify.cash workflow runs for ${workflow}...`);
return this.octokit.actions.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
workflow_id: workflow,
})
.then(response => lodashGet(response, 'data.workflow_runs[0].id'));
}

/**
* Generate the well-formatted body of a production release.
*
Expand Down
52 changes: 48 additions & 4 deletions .github/actions/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ module.exports =

const core = __nccwpck_require__(2186);
const github = __nccwpck_require__(5438);
const ActionUtils = __nccwpck_require__(970);
const GithubUtils = __nccwpck_require__(7999);

const prList = JSON.parse(core.getInput('PR_LIST', {required: true}));
const isProd = JSON.parse(
core.getInput('IS_PRODUCTION_DEPLOY', {required: true}),
);
const prList = ActionUtils.getJSONInput('PR_LIST', {required: true});
const isProd = ActionUtils.getJSONInput('IS_PRODUCTION_DEPLOY', {required: true});
const version = core.getInput('DEPLOY_VERSION', {required: true});
const token = core.getInput('GITHUB_TOKEN', {required: true});
const octokit = github.getOctokit(token);
Expand Down Expand Up @@ -68,6 +67,35 @@ prList.forEach((pr) => {
});


/***/ }),

/***/ 970:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const core = __nccwpck_require__(2186);

/**
* Safely parse a JSON input to a GitHub Action.
*
* @param {String} name - The name of the input.
* @param {Object} options - Options to pass to core.getInput
* @param {*} [defaultValue] - A default value to provide for the input.
* Not required if the {required: true} option is given in the second arg to this function.
* @returns {any}
*/
function getJSONInput(name, options, defaultValue = undefined) {
const input = core.getInput(name, options);
if (input) {
return JSON.parse(input);
}
return defaultValue;
}

module.exports = {
getJSONInput,
};


/***/ }),

/***/ 7999:
Expand Down Expand Up @@ -381,6 +409,22 @@ class GithubUtils {
});
}

/**
* Get the most recent workflow run for the given Expensify.cash workflow.
*
* @param {String} workflow
* @returns {Promise}
*/
getLatestWorkflowRunID(workflow) {
console.log(`Fetching Expensify.cash workflow runs for ${workflow}...`);
return this.octokit.actions.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
workflow_id: workflow,
})
.then(response => lodashGet(response, 'data.workflow_runs[0].id'));
}

/**
* Generate the well-formatted body of a production release.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const core = require('@actions/core');
const github = require('@actions/github');
const ActionUtils = require('../../libs/ActionUtils');
const GithubUtils = require('../../libs/GithubUtils');

const prList = JSON.parse(core.getInput('PR_LIST', {required: true}));
const isProd = JSON.parse(
core.getInput('IS_PRODUCTION_DEPLOY', {required: true}),
);
const prList = ActionUtils.getJSONInput('PR_LIST', {required: true});
const isProd = ActionUtils.getJSONInput('IS_PRODUCTION_DEPLOY', {required: true});
const version = core.getInput('DEPLOY_VERSION', {required: true});
const token = core.getInput('GITHUB_TOKEN', {required: true});
const octokit = github.getOctokit(token);
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/reopenIssueWithComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,22 @@ class GithubUtils {
});
}

/**
* Get the most recent workflow run for the given Expensify.cash workflow.
*
* @param {String} workflow
* @returns {Promise}
*/
getLatestWorkflowRunID(workflow) {
console.log(`Fetching Expensify.cash workflow runs for ${workflow}...`);
return this.octokit.actions.listWorkflowRuns({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
workflow_id: workflow,
})
.then(response => lodashGet(response, 'data.workflow_runs[0].id'));
}

/**
* Generate the well-formatted body of a production release.
*
Expand Down
16 changes: 16 additions & 0 deletions .github/actions/triggerWorkflowAndWait/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Trigger workflow and wait'
description: 'This action triggers a workflow in another repository and waits for the result.'
inputs:
GITHUB_TOKEN:
description: 'Auth token for Expensify.cash Github; necessary for accessing Octokit.'
required: true
WORKFLOW:
description: 'The reference point. For example, you could use main.yml.'
required: true
INPUTS:
description: 'Inputs to pass to the workflow, must be a JSON string'
required: false

runs:
using: 'node12'
main: './index.js'
Loading