From 9bb7ba3382fd6f90d0128f6ea31f5a269cead5ba Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 25 Jul 2024 16:48:45 -0700 Subject: [PATCH 1/2] Correctly target last completed deploy --- .../getDeployPullRequestList/getDeployPullRequestList.ts | 3 ++- .github/actions/javascript/getDeployPullRequestList/index.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 08519c40413b..ad6c9b5508e0 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -40,10 +40,11 @@ async function run() { }) ).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success') ) { + console.log(`Deploy was not a success: ${lastSuccessfulDeploy.html_url}, looking at the next one`); lastSuccessfulDeploy = completedDeploys.shift(); } - const priorTag = completedDeploys[0].head_branch; + const priorTag = lastSuccessfulDeploy.head_branch; console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`); const prList = await GitUtils.getPullRequestsMergedBetween(priorTag ?? '', inputTag); console.log('Found the pull request list: ', prList); diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index cfe512076ecd..2142f8f3a459 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11529,9 +11529,10 @@ async function run() { run_id: lastSuccessfulDeploy.id, filter: 'latest', })).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success')) { + console.log(`Deploy was not a success: ${lastSuccessfulDeploy.html_url}, looking at the next one`); lastSuccessfulDeploy = completedDeploys.shift(); } - const priorTag = completedDeploys[0].head_branch; + const priorTag = lastSuccessfulDeploy.head_branch; console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`); const prList = await GitUtils_1.default.getPullRequestsMergedBetween(priorTag ?? '', inputTag); console.log('Found the pull request list: ', prList); From 64b98b9b903c3c9d439972161118d92d191c2a43 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 25 Jul 2024 16:52:17 -0700 Subject: [PATCH 2/2] Fix ts error --- .../getDeployPullRequestList/getDeployPullRequestList.ts | 4 ++++ .github/actions/javascript/getDeployPullRequestList/index.js | 3 +++ 2 files changed, 7 insertions(+) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index ad6c9b5508e0..c15036c93232 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -44,6 +44,10 @@ async function run() { lastSuccessfulDeploy = completedDeploys.shift(); } + if (!lastSuccessfulDeploy) { + throw new Error('Could not find a prior successful deploy'); + } + const priorTag = lastSuccessfulDeploy.head_branch; console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`); const prList = await GitUtils.getPullRequestsMergedBetween(priorTag ?? '', inputTag); diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 2142f8f3a459..999c2e9370ae 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11532,6 +11532,9 @@ async function run() { console.log(`Deploy was not a success: ${lastSuccessfulDeploy.html_url}, looking at the next one`); lastSuccessfulDeploy = completedDeploys.shift(); } + if (!lastSuccessfulDeploy) { + throw new Error('Could not find a prior successful deploy'); + } const priorTag = lastSuccessfulDeploy.head_branch; console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`); const prList = await GitUtils_1.default.getPullRequestsMergedBetween(priorTag ?? '', inputTag);