-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
19,880 additions
and
138 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,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' |
65 changes: 65 additions & 0 deletions
65
.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.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 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); | ||
}); |
Oops, something went wrong.