-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multiple amplify URIs in monorepos (#64)
* Add support for multiple amplify URIs in monorepos * Remove storybook * Fix multiple amplify * Improve naming
- Loading branch information
Showing
2 changed files
with
42 additions
and
26 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 |
---|---|---|
@@ -1,20 +1,26 @@ | ||
const core = require("@actions/core"); | ||
const github = require("@actions/github"); | ||
|
||
exports.getAmplifyURI = async function getAmplifyURI() { | ||
exports.getAmplifyURIs = async function getAmplifyURI() { | ||
const pullRequest = github.context.payload.pull_request; | ||
const amplifyUri = core.getInput("amplify-uri"); | ||
if (!amplifyUri) { | ||
const labels = pullRequest.labels.map((label) => label.name); | ||
const amplifyUriRaw = core.getInput("amplify-uri"); | ||
if (!amplifyUriRaw) { | ||
return; | ||
} | ||
return amplifyUri.replace("%", pullRequest.number); | ||
}; | ||
|
||
exports.getStorybookAmplifyUri = async function getStorybookAmplifyUri() { | ||
const pullRequest = github.context.payload.pull_request; | ||
const storybookAmplifyUri = core.getInput("storybook-amplify-uri"); | ||
if (!storybookAmplifyUri) { | ||
return; | ||
const amplifyUri = amplifyUriRaw.replace(/%/g, pullRequest.number); | ||
if (amplifyUri.match(/^{/)) { | ||
const result = []; | ||
const amplifyUris = JSON.parse(amplifyUri); | ||
for (const label of labels) { | ||
if (amplifyUris[label]) { | ||
result.push(amplifyUris[label]); | ||
} | ||
} | ||
return result; | ||
} else if (!amplifyUri) { | ||
return null; | ||
} else { | ||
return [amplifyUri]; | ||
} | ||
return storybookAmplifyUri.replace("%", pullRequest.number); | ||
}; |
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