From 7736d93d3f497d26066a3dbabe16400004cda1ee Mon Sep 17 00:00:00 2001 From: Philippe Auriach <920265+philippeauriach@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:33:25 +0100 Subject: [PATCH] feat: add linear previews links [DEVOP-330] (#103) --- lib/actions/amplify.js | 8 ++++++-- lib/actions/pullRequest.js | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/actions/amplify.js b/lib/actions/amplify.js index f5dfb24b..2be2ca78 100644 --- a/lib/actions/amplify.js +++ b/lib/actions/amplify.js @@ -24,14 +24,18 @@ exports.getAmplifyURIs = async function getAmplifyURI() { ); if (hasAtLeastOnePackageOrConfig) { - return { links: Object.values(amplifyUris) }; + return { + links: Object.entries(amplifyUris).reduce((acc, [label, url]) => { + return { ...acc, label, url }; + }, {}), + }; } const links = []; const hiddenLinks = []; for (const label of labels) { if (amplifyUris[label]) { - links.push(amplifyUris[label]); + links.push({ label, url: amplifyUris[label] }); } } for (const [key, url] of Object.entries(amplifyUris)) { diff --git a/lib/actions/pullRequest.js b/lib/actions/pullRequest.js index 8fb5bf5d..48ff605b 100644 --- a/lib/actions/pullRequest.js +++ b/lib/actions/pullRequest.js @@ -97,7 +97,9 @@ exports.validatePR = async function validatePR({ pullRequest, issue }) { const body = "AWS Amplify live test URI:\n" + "- " + - amplifyUris.join("\n- ") + + amplifyUris + .map((elt) => `[${elt.label?.split("/")?.pop()} preview](${elt.url})`) + .join("\n- ") + hiddenAmplifyText; const previousComments = comments.filter(({ body }) => body.match(/AWS Amplify live/)