Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 12 additions & 20 deletions lib/actions/amplify.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,22 @@ exports.getAmplifyURIs = async function getAmplifyURI() {
(label) => label.startsWith("packages/") || label.startsWith("configs/")
);

if (hasAtLeastOnePackageOrConfig) {
const allLinks = Object.entries(amplifyUris).map(([label, url]) => {
const hasLabel = labels.some((l) => label.includes(l));
return {
links: Object.entries(amplifyUris).map(([label, url]) => {
return { label, url };
}),
label,
url,
isVisibleInComment: hasAtLeastOnePackageOrConfig || hasLabel,
hasPreview: hasLabel,
};
}

const links = [];
const hiddenLinks = [];
for (const label of labels) {
if (amplifyUris[label]) {
links.push({ label, url: amplifyUris[label] });
}
}
for (const [key, url] of Object.entries(amplifyUris)) {
if (!labels.includes(key)) {
hiddenLinks.push(url);
}
}
return { links, hiddenLinks };
});
return {
links: allLinks.filter((l) => l.isVisibleInComment),
hiddenLinks: allLinks.filter((l) => !l.isVisibleInComment),
};
} else if (!amplifyUri) {
return {};
} else {
return { links: [amplifyUri] };
return { links: [{ url: amplifyUri, hasPreview: true }] };
}
};
10 changes: 9 additions & 1 deletion lib/actions/pullRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ exports.validatePR = async function validatePR({ pullRequest, issue }) {
"AWS Amplify live test URI:\n" +
"- " +
amplifyUris
.map((elt) => `[${elt.label?.split("/")?.pop()} preview](${elt.url})`)
.map(
(elt) =>
`[${[
elt.label?.split("/")?.pop(),
elt.hasPreview ? " preview" : undefined, // any link with "preview" in the label will be displayed in the linked linear issue
]
.filter(Boolean)
.join(" ")}](${elt.url})`
)
.join("\n- ") +
hiddenAmplifyText;
const previousComments = comments.filter(({ body }) =>
Expand Down