Skip to content

Commit

Permalink
Merge pull request #48635 from rayane-djouah/Combine-deploy.yml-and-p…
Browse files Browse the repository at this point in the history
…latformDeploy.yml

[No QA] Combine deploy.yml and platformDeploy.yml

(cherry picked from commit 15f44f0)

(CP triggered by roryabraham)
  • Loading branch information
roryabraham authored and OSBotify committed Sep 6, 2024
1 parent 64d28f0 commit 2eea921
Show file tree
Hide file tree
Showing 8 changed files with 625 additions and 515 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function run() {
GitHubUtils.octokit.actions.listWorkflowRuns({
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
workflow_id: 'platformDeploy.yml',
workflow_id: 'deploy.yml',
event: 'push',
branch: tag,
}),
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12138,7 +12138,7 @@ function run() {
GithubUtils_1.default.octokit.actions.listWorkflowRuns({
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
workflow_id: 'platformDeploy.yml',
workflow_id: 'deploy.yml',
event: 'push',
branch: tag,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function isReleaseValidBaseForEnvironment(releaseTag: string, isProduction
}

/**
* Was a given platformDeploy workflow run successful on at least one platform?
* Was a given deploy workflow run successful on at least one platform?
*/
async function wasDeploySuccessful(runID: number) {
const jobsForWorkflowRun = (
Expand Down Expand Up @@ -82,7 +82,7 @@ async function run() {

console.log(`Looking for PRs deployed to ${deployEnv} in ${inputTag}...`);

const completedDeploys = (
const platformDeploys = (
await GithubUtils.octokit.actions.listWorkflowRuns({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
Expand All @@ -95,6 +95,24 @@ async function run() {
// because if a build fails on even one platform, then it will have the status 'failure'
.filter((workflowRun) => workflowRun.conclusion !== 'cancelled');

const deploys = (
await GithubUtils.octokit.actions.listWorkflowRuns({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
// eslint-disable-next-line @typescript-eslint/naming-convention
workflow_id: 'deploy.yml',
status: 'completed',
})
).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');

// W've combined platformDeploy.yml and deploy.yml
// TODO: Remove this once there are successful staging and production deploys using the new deploy.yml workflow
const completedDeploys = [...deploys, ...platformDeploys];
completedDeploys.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());

// Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully
let lastSuccessfulDeploy = completedDeploys.shift();

Expand Down
18 changes: 16 additions & 2 deletions .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11526,7 +11526,7 @@ async function isReleaseValidBaseForEnvironment(releaseTag, isProductionDeploy)
return !isPrerelease;
}
/**
* Was a given platformDeploy workflow run successful on at least one platform?
* Was a given deploy workflow run successful on at least one platform?
*/
async function wasDeploySuccessful(runID) {
const jobsForWorkflowRun = (await GithubUtils_1.default.octokit.actions.listJobsForWorkflowRun({
Expand Down Expand Up @@ -11566,7 +11566,7 @@ async function run() {
const isProductionDeploy = !!(0, ActionUtils_1.getJSONInput)('IS_PRODUCTION_DEPLOY', { required: false }, false);
const deployEnv = isProductionDeploy ? 'production' : 'staging';
console.log(`Looking for PRs deployed to ${deployEnv} in ${inputTag}...`);
const completedDeploys = (await GithubUtils_1.default.octokit.actions.listWorkflowRuns({
const platformDeploys = (await GithubUtils_1.default.octokit.actions.listWorkflowRuns({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand All @@ -11576,6 +11576,20 @@ async function run() {
// 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');
const deploys = (await GithubUtils_1.default.octokit.actions.listWorkflowRuns({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
// eslint-disable-next-line @typescript-eslint/naming-convention
workflow_id: 'deploy.yml',
status: 'completed',
})).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');
// W've combined platformDeploy.yml and deploy.yml
// TODO: Remove this once there are successful staging and production deploys using the new deploy.yml workflow
const completedDeploys = [...deploys, ...platformDeploys];
completedDeploys.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
// Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully
let lastSuccessfulDeploy = completedDeploys.shift();
if (!lastSuccessfulDeploy) {
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/validateActionsAndWorkflows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ for ((i=0; i < ${#WORKFLOWS[@]}; i++)); do
# Skip linting e2e workflow due to bug here: https://github.com/SchemaStore/schemastore/issues/2579
if [[ "$WORKFLOW" == './workflows/e2ePerformanceTests.yml'
|| "$WORKFLOW" == './workflows/testBuild.yml'
|| "$WORKFLOW" == './workflows/platformDeploy.yml' ]]; then
|| "$WORKFLOW" == './workflows/deploy.yml' ]]; then
continue
fi

Expand Down
Loading

0 comments on commit 2eea921

Please sign in to comment.