diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index ecf242f00cc20..08519c40413b7 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -21,7 +21,27 @@ async function run() { status: 'completed', event: isProductionDeploy ? 'release' : 'push', }) - ).data.workflow_runs; + ).data.workflow_runs + // Note: we filter out cancelled runs instead of looking only for success runs + // because if a build fails on even one platform, then it will have the status 'failure' + .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); + + // Find the most recent deploy workflow for which at least one of the build jobs finished successfully. + let lastSuccessfulDeploy = completedDeploys.shift(); + while ( + lastSuccessfulDeploy && + !( + await GithubUtils.octokit.actions.listJobsForWorkflowRun({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + // eslint-disable-next-line @typescript-eslint/naming-convention + run_id: lastSuccessfulDeploy.id, + filter: 'latest', + }) + ).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success') + ) { + lastSuccessfulDeploy = completedDeploys.shift(); + } const priorTag = completedDeploys[0].head_branch; console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`); diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 6b956f17be258..cfe512076ecd8 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11515,7 +11515,22 @@ async function run() { workflow_id: 'platformDeploy.yml', status: 'completed', event: isProductionDeploy ? 'release' : 'push', - })).data.workflow_runs; + })).data.workflow_runs + // Note: we filter out cancelled runs instead of looking only for success runs + // because if a build fails on even one platform, then it will have the status 'failure' + .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); + // Find the most recent deploy workflow for which at least one of the build jobs finished successfully. + let lastSuccessfulDeploy = completedDeploys.shift(); + while (lastSuccessfulDeploy && + !(await GithubUtils_1.default.octokit.actions.listJobsForWorkflowRun({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + // eslint-disable-next-line @typescript-eslint/naming-convention + run_id: lastSuccessfulDeploy.id, + filter: 'latest', + })).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success')) { + lastSuccessfulDeploy = completedDeploys.shift(); + } const priorTag = completedDeploys[0].head_branch; console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`); const prList = await GitUtils_1.default.getPullRequestsMergedBetween(priorTag ?? '', inputTag);