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

New GH Action: CreateOrUpdateStagingDeployCash #1703

Merged
merged 54 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c41e53e
Fix comparison URL in new StagingDeployCash
roryabraham Mar 10, 2021
a3f67ef
Merge branch 'master' into Rory-CreateOrUpdateStagingDeployCash
roryabraham Mar 10, 2021
0e7c78a
Add new action to buildActions script
roryabraham Mar 10, 2021
b851bb1
Remove unnecessary class from GitUtils
roryabraham Mar 10, 2021
216dd96
Implement new CreateOrUpdateStagingDeployCash action
roryabraham Mar 10, 2021
bc2ba6c
Merge branch 'master' into Rory-CreateOrUpdateStagingDeployCash
roryabraham Mar 11, 2021
bd3f00d
Cleanup formatting of StagingDeployCash
roryabraham Mar 11, 2021
6c03316
Switch to E.cash repo and add early return
roryabraham Mar 11, 2021
0a7eed1
Simplify promise chain
roryabraham Mar 11, 2021
b441e9b
Trim comma-separated list items
roryabraham Mar 11, 2021
4bc427f
Setup test in workflow
roryabraham Mar 11, 2021
364d0e6
Fix yaml syntax error
roryabraham Mar 11, 2021
73dfa84
Fix action name
roryabraham Mar 11, 2021
6365b78
Add more verbose logging and state filter
roryabraham Mar 11, 2021
27bc8e6
Update ref
roryabraham Mar 11, 2021
6b4559a
Rebuild GH actions
roryabraham Mar 11, 2021
6a53960
Update ref
roryabraham Mar 11, 2021
68df618
Use constant for label
roryabraham Mar 11, 2021
7d6f060
Update ref
roryabraham Mar 11, 2021
fd0cec1
Enable verbose logging of octokit
roryabraham Mar 11, 2021
62339b4
Update ref
roryabraham Mar 11, 2021
41e2f57
Enable module-level verbose logging
roryabraham Mar 11, 2021
1a3422b
Update ref
roryabraham Mar 11, 2021
95f5159
Make labels an array
roryabraham Mar 11, 2021
939a863
Update ref
roryabraham Mar 11, 2021
6d51d6a
Use plugin for extra extra verbose output
roryabraham Mar 11, 2021
7f45a53
Update ref
roryabraham Mar 11, 2021
0927a8e
Try to catch the error and print it
roryabraham Mar 11, 2021
5295dec
Update ref
roryabraham Mar 11, 2021
f9c0313
Add another log line
roryabraham Mar 11, 2021
532fd83
Update ref
roryabraham Mar 11, 2021
4de700a
Log last tag
roryabraham Mar 11, 2021
a20a1ef
Update ref
roryabraham Mar 11, 2021
e9eb118
Wrap labels in array for create request
roryabraham Mar 11, 2021
95bd4ed
Update ref
roryabraham Mar 11, 2021
e151c48
Make assignees field use an array too
roryabraham Mar 11, 2021
f9329ac
Update ref
roryabraham Mar 11, 2021
5bf729a
Merge branch 'master' into Rory-CreateOrUpdateStagingDeployCash
roryabraham Mar 11, 2021
74b813a
Rebuild GH actions
roryabraham Mar 11, 2021
b9a6180
Update ref
roryabraham Mar 11, 2021
a808feb
Use html url and log errors
roryabraham Mar 11, 2021
3f0c79e
Update ref
roryabraham Mar 11, 2021
318e1d8
Improve error handling and logging
roryabraham Mar 11, 2021
e917a9a
Update ref
roryabraham Mar 11, 2021
6033c21
Add lots of temp debug logs
roryabraham Mar 11, 2021
b2f710a
Update ref
roryabraham Mar 11, 2021
29da803
Add better error handling in getDeployBlockers
roryabraham Mar 11, 2021
3ea1647
Update ref
roryabraham Mar 11, 2021
ee3f7b7
Get rid of debug logs and force-exit node script to break promise chain
roryabraham Mar 11, 2021
421ec1f
update ref
roryabraham Mar 11, 2021
f421c2f
Reset test workflow
roryabraham Mar 11, 2021
3eac805
Rebuild GH actions
roryabraham Mar 11, 2021
523a3ea
Merge branch 'master' into Rory-CreateOrUpdateStagingDeployCash
roryabraham Mar 12, 2021
effb7c3
Rebuild GH actions
roryabraham Mar 12, 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
18 changes: 18 additions & 0 deletions .github/actions/createOrUpdateStagingDeploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Create or Update StagingDeployCash'
description: 'Creates a new StagingDeployCash issue if there is not one open, or updates the existing one.'
inputs:
NPM_VERSION:
description: The new NPM version of the StagingDeployCash issue.
required: true
GITHUB_TOKEN:
description: Auth token for Expensify.cash Github
required: true
NEW_PULL_REQUESTS:
description: A comma-separated list of pull request URLs to add to the open StagingDeployCash issue.
required: false
NEW_DEPLOY_BLOCKERS:
description: A comma-separated list of deploy blockers to add to the open StagingDeployCash issue.
required: false
runs:
using: 'node12'
main: './index.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 moment = require('moment');
const GithubUtils = require('../../libs/GithubUtils');
const GitUtils = require('../../libs/GitUtils');

const newVersion = core.getInput('NPM_VERSION', {required: true});
const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
const githubUtils = new GithubUtils(octokit);

githubUtils.getStagingDeployCash()
.then(() => githubUtils.updateStagingDeployCash(
newVersion,
_.map(core.getInput('NEW_PULL_REQUESTS').split(','), PR => PR.trim()) || [],
_.map(core.getInput('NEW_DEPLOY_BLOCKERS').split(','), deployBlocker => deployBlocker.trim()) || [],
))
.then(({data}) => {
console.log('Successfully updated StagingDeployCash!', data.html_url);
process.exit(0);
})
.catch((err) => {
// Unable to find the open StagingDeployCash
if (err && err.code === 404) {
console.log('No open StagingDeployCash found, creating a new one.');

// Fetch all the StagingDeployCash issues
return octokit.issues.listForRepo({
log: console,
owner: GithubUtils.GITHUB_OWNER,
repo: GithubUtils.EXPENSIFY_CASH_REPO,
labels: GithubUtils.STAGING_DEPLOY_CASH_LABEL,
state: 'closed',
});
}

// Unexpected error!
console.error('Unexpected error occurred finding the StagingDeployCash!'
+ ' There may have been more than one open StagingDeployCash found,'
+ ' or there was some other problem with the Github API request.', err);
core.setFailed(err);
})
.then((githubResponse) => {
if (!githubResponse || !githubResponse.data || _.isEmpty(githubResponse.data)) {
console.error('Failed fetching data from Github!', githubResponse);
throw new Error('Failed fetching data from Github');
}

// Parse the tag from the most recent StagingDeployCash
const lastTag = githubUtils.getStagingDeployCashData(githubResponse.data[0]).tag;
console.log('Found tag of previous StagingDeployCash:', lastTag);

// Find the list of PRs merged between the last StagingDeployCash and the new version
return GitUtils.getPullRequestsMergedBetween(lastTag, newVersion);
})
.then(PRNumbers => githubUtils.createNewStagingDeployCash(
`Deploy Checklist: Expensify.cash ${moment().format('YYYY-MM-DD')}`,
newVersion,
_.map(PRNumbers, GithubUtils.getPullRequestURLFromNumber),
))
.then(({data}) => console.log('Successfully created new StagingDeployCash!', data.html_url))
.catch((err) => {
console.error('An error occurred!', err);
core.setFailed(err);
});
Loading