Skip to content

Commit

Permalink
Merge pull request Expensify#44581 from Expensify/Rory-FixDeployComments
Browse files Browse the repository at this point in the history
[No QA] Fix deploy comments if a deploy is cancelled in progress
  • Loading branch information
Julesssss authored Jun 28, 2024
2 parents 1389d1b + 5532a67 commit 58a724e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
17 changes: 16 additions & 1 deletion .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 58a724e

Please sign in to comment.