-
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.
Merge pull request #9792 from Expensify/update-staging-from-main
Update version to 1.1.82-4 on staging
- Loading branch information
Showing
15 changed files
with
33,155 additions
and
7 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: 'Get Release Pull Request List' | ||
description: 'Gather all the PRs being deployed for given release tag.' | ||
inputs: | ||
TAG: | ||
description: Git tag | ||
required: true | ||
GITHUB_TOKEN: | ||
description: "Github token for authentication" | ||
required: true | ||
IS_PRODUCTION_DEPLOY: | ||
description: "True if we are deploying to production" | ||
required: false | ||
outputs: | ||
PR_LIST: | ||
description: Array of pull request numbers | ||
runs: | ||
using: 'node12' | ||
main: './index.js' |
62 changes: 62 additions & 0 deletions
62
.github/actions/getDeployPullRequestList/getDeployPullRequestList.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,62 @@ | ||
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 = ActionUtils.getJSONInput('IS_PRODUCTION_DEPLOY', {required: false}, false); | ||
const itemToFetch = isProductionDeploy ? 'release' : 'tag'; | ||
|
||
/** | ||
* Gets either releases or tags for a GitHub repo | ||
* | ||
* @param {boolean} fetchReleases | ||
* @returns {*} | ||
*/ | ||
function getTagsOrReleases(fetchReleases) { | ||
if (fetchReleases) { | ||
return octokit.repos.listReleases({ | ||
owner: github.context.repo.owner, | ||
repo: github.context.repo.repo, | ||
}); | ||
} | ||
|
||
return octokit.repos.listTags({ | ||
owner: github.context.repo.owner, | ||
repo: github.context.repo.repo, | ||
}); | ||
} | ||
|
||
console.log(`Fetching ${itemToFetch} list from github...`); | ||
getTagsOrReleases(isProductionDeploy) | ||
.catch(githubError => core.setFailed(githubError)) | ||
.then(({data}) => { | ||
const keyToPluck = isProductionDeploy ? 'tag_name' : 'name'; | ||
const tags = _.pluck(data, keyToPluck); | ||
const priorTagIndex = _.indexOf(tags, inputTag) + 1; | ||
|
||
if (priorTagIndex === 0) { | ||
console.log(`No ${itemToFetch} was found for input tag ${inputTag}.` | ||
+ `Comparing it to latest ${itemToFetch} ${tags[0]}`); | ||
} | ||
|
||
if (priorTagIndex === tags.length) { | ||
const err = new Error('Somehow, the input tag was at the end of the paginated result, ' | ||
+ 'so we don\'t have the prior tag'); | ||
console.error(err.message); | ||
core.setFailed(err); | ||
return; | ||
} | ||
|
||
const priorTag = tags[priorTagIndex]; | ||
console.log(`Given ${itemToFetch}: ${inputTag}`); | ||
console.log(`Prior ${itemToFetch}: ${priorTag}`); | ||
|
||
const pullRequestList = GitUtils.getPullRequestsMergedBetween(priorTag, inputTag); | ||
console.log(`Found the pull request list: ${pullRequestList}`); | ||
return core.setOutput('PR_LIST', pullRequestList); | ||
}) | ||
.catch(error => core.setFailed(error)); |
Oops, something went wrong.