From 23767bd4dee5c717bfb59d6f49d743b479133711 Mon Sep 17 00:00:00 2001 From: Sonja Popovic Date: Thu, 27 Feb 2025 12:05:16 +0100 Subject: [PATCH] MWPW-167901- add authorization for branch url check on github test run, since aem.live is protected --- nala/libs/baseurl.js | 5 +++-- nala/utils/global.setup.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nala/libs/baseurl.js b/nala/libs/baseurl.js index e7f3811..fd6c41d 100644 --- a/nala/libs/baseurl.js +++ b/nala/libs/baseurl.js @@ -1,8 +1,9 @@ import pkg from 'axios'; const { head } = pkg; -export async function isBranchURLValid(url) { +export async function isBranchURLValid(url, includeAuthorization = false) { try { - const response = await head(url); + const headers = includeAuthorization ? { Authorization: `token ${process.env.MILO_AEM_API_KEY}` } : {}; + const response = await head(url, { headers }); if (response.status === 200) { console.info(`\nURL (${url}) returned a 200 status code. It is valid.`); return true; diff --git a/nala/utils/global.setup.js b/nala/utils/global.setup.js index c858efe..d6fdfb8 100644 --- a/nala/utils/global.setup.js +++ b/nala/utils/global.setup.js @@ -29,7 +29,7 @@ async function getGitHubPRBranchLiveUrl() { const prBranchLiveUrl = `https://${prBranch}--${prFromRepoName}--${prFromOrg}.aem.live`; try { - if (await isBranchURLValid(prBranchLiveUrl)) { + if (await isBranchURLValid(prBranchLiveUrl, true)) { process.env.PR_BRANCH_LIVE_URL = prBranchLiveUrl; } console.info('PR Repository : ', repository);