Skip to content

Commit

Permalink
(docs): docs deployment for release branches (#22399)
Browse files Browse the repository at this point in the history
Note: requires changes from following PR
#22252

Updated build-docs to trigger on release branches. 
Now includes a stage before deployment to check if triggering branch
version matches a latest minor version of a major release.
  • Loading branch information
zhenmichael authored and sonalideshpandemsft committed Oct 7, 2024
1 parent 2fe27d5 commit c133190
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,23 @@ export default class LatestVersionsCommand extends BaseCommand<typeof LatestVers
this.log(
`Version ${versionInput.version} is the latest version for major version ${majorVersion}`,
);
this.log(`##vso[task.setvariable variable=shouldDeploy;isOutput=true]true`);
return;
}

// If versions do not match on first major version encounter, then the input version is not the latest
this.error(
`skipping deployment stage. input version ${versionInput.version} does not match the latest version ${v.version}`,
{ exit: 1 },
this.log(
`##[warning]skipping deployment stage. input version ${versionInput.version} does not match the latest version ${v.version}`,
);
this.log(`##vso[task.setvariable variable=shouldDeploy;isOutput=true]false`);
return;
}
}

// Error if no major version corresponds to input version
this.error(
`No major version found corresponding to input version ${versionInput.version}`,
{ exit: 1 },
this.log(
`##[warning]No major version found corresponding to input version ${versionInput.version}`,
);
this.log(`##vso[task.setvariable variable=shouldDeploy;isOutput=true]false`);
}
}
37 changes: 35 additions & 2 deletions tools/pipelines/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ variables:
trigger:
branches:
include:
# - release/*
- release/*
- main
pr: none

Expand Down Expand Up @@ -301,10 +301,43 @@ stages:
workingDir: $(Build.SourcesDirectory)/docs
customCommand: 'run ci:linkcheck'

- stage: check_branch_version
displayName: 'Check Version Deployment Condition'
pool: Small
jobs:
- job: check_branch_version
displayName: 'Check Version Deployment Condition'
steps:
- template: /tools/pipelines/templates/include-install-build-tools.yml
parameters:
buildDirectory: $(Build.SourcesDirectory)
- task: Bash@3
name: SetVersion
displayName: 'Set Build Version'
env:
VERSION_BUILDNUMBER: $(Build.BuildNumber)
inputs:
targetType: 'inline'
workingDirectory: $(Build.SourcesDirectory)
script: |
# Generate the build version. Sets the environment variables version, codeVersion, and isLatest.
flub generate buildVersion
- task: Bash@3
name: SetShouldDeploy
displayName: 'Check Version Deployment Condition'
inputs:
targetType: 'inline'
workingDirectory: $(Build.SourcesDirectory)
script: |
# Check if the version is the latest minor of its corresponding major version series
# Sets variable shouldDeploy to true if the version is the latest minor and false otherwise
flub check latestVersions $(SetVersion.version) client
- stage: deploy
displayName: 'Deploy website'
pool: Small
dependsOn: ['build', 'guardian']
dependsOn: ['build', 'guardian', 'check_branch_version']
condition: eq(dependencies.check_branch_version.outputs['check_branch_version.SetShouldDeploy.shouldDeploy'], 'true')
jobs:
- job: deploy_site
displayName: 'Deploy website'
Expand Down

0 comments on commit c133190

Please sign in to comment.