-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync eng/common directory with azure-sdk-tools for PR 1725 (#19584)
* Bring changes from JS docs metadata * Move business logic inside Update-DocsMsMetadata.ps1 * Update with the latest changes in JS PR * Update from latest PR feedback * Add check for empty path to prevent crashes when creating relative paths Co-authored-by: Daniel Jurek <djurek@microsoft.com>
- Loading branch information
1 parent
e049e5b
commit db5125e
Showing
11 changed files
with
474 additions
and
19 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
eng/common/pipelines/templates/steps/enable-long-path-support.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
steps: | ||
- pwsh: | | ||
if ($IsWindows) { | ||
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem /f /v LongPathsEnabled /t REG_DWORD /d 1 | ||
git config --system core.longpaths true | ||
} | ||
else { | ||
Write-Host "This script is not executing on Windows, skipping registry modification." | ||
} | ||
displayName: Enable long path support if necessary |
14 changes: 14 additions & 0 deletions
14
eng/common/pipelines/templates/steps/set-daily-docs-branch-name.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
parameters: | ||
- name: DailyBranchVariableName | ||
type: string | ||
default: TargetBranchName | ||
|
||
steps: | ||
- pwsh: | | ||
$branchName = $env:DAILYDOCSBRANCHNAMEOVERRIDE | ||
if (!$branchName) { | ||
$branchName = "daily/$(Get-Date -Format 'yyyy-MM-dd')" | ||
} | ||
Write-Host "Daily Branch Name: $branchName" | ||
Write-Host "##vso[task.setvariable variable=${{ parameters.DailyBranchVariableName }};]$branchName" | ||
displayName: Set daily docs branch name in $(${{ parameters.DailyBranchVariableName }}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
parameters: | ||
WorkingDirectory: '$(System.DefaultWorkingDirectory)' | ||
RemoteRepo: 'origin' | ||
DefaultBranchVariableName: DefaultBranch | ||
steps: | ||
- pwsh: | | ||
$setDefaultBranch = (git remote show ${{ parameters.RemoteRepo }} | Out-String) -replace "(?ms).*HEAD branch: (\w+).*", '$1' | ||
if ($LASTEXITCODE -ne 0) { | ||
Write-Host "Not able to fetch the default branch from git command. Set to main." | ||
$setDefaultBranch = 'main' | ||
} | ||
Write-Host "Setting DefaultBranch=$setDefaultBranch" | ||
Write-Host "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch" | ||
Write-Host "Setting ${{ parameters.DefaultBranchVariableName }}=$setDefaultBranch" | ||
Write-Host "##vso[task.setvariable variable=${{ parameters.DefaultBranchVariableName }}]$setDefaultBranch" | ||
displayName: "Setup Default Branch" | ||
workingDirectory: ${{ parameters.workingDirectory }} | ||
ignoreLASTEXITCODE: true |
95 changes: 95 additions & 0 deletions
95
eng/common/pipelines/templates/steps/update-docsms-metadata.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
parameters: | ||
- name: PackageInfoLocations | ||
type: object | ||
default: [] | ||
- name: RepoId | ||
type: string | ||
default: $(Build.Repository.Name) | ||
- name: WorkingDirectory | ||
type: string | ||
default: '' | ||
- name: ScriptDirectory | ||
type: string | ||
default: eng/common/scripts | ||
- name: TargetDocRepoName | ||
type: string | ||
default: '' | ||
- name: TargetDocRepoOwner | ||
type: string | ||
- name: Language | ||
type: string | ||
default: '' | ||
- name: DailyDocsBuild | ||
type: boolean | ||
default: false | ||
- name: SparseCheckoutPaths | ||
type: object | ||
default: | ||
- '**' | ||
|
||
steps: | ||
- template: /eng/common/pipelines/templates/steps/enable-long-path-support.yml | ||
|
||
- pwsh: | | ||
Write-Host "###vso[task.setvariable variable=DocRepoLocation]${{ parameters.WorkingDirectory }}/doc" | ||
displayName: Set $(DocRepoLocation) | ||
|
||
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml | ||
parameters: | ||
SkipDefaultCheckout: true | ||
Repositories: | ||
- Name: ${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} | ||
WorkingDirectory: $(DocRepoLocation) | ||
Paths: ${{ parameters.SparseCheckoutPaths }} | ||
|
||
# If performing a daily docs build set the $(TargetBranchName) to a daily branch | ||
# name and attempt to checkout the daily docs branch. If the branch doesn't | ||
# exist, create it | ||
- ${{ if eq(parameters.DailyDocsBuild, 'true') }}: | ||
- template: /eng/common/pipelines/templates/steps/set-daily-docs-branch-name.yml | ||
|
||
- pwsh: | | ||
$ErrorActionPreference = "Continue" | ||
$RemoteName = "origin" | ||
$BranchName = "$(TargetBranchName)" | ||
# Fetch and checkout remote branch if it already exists otherwise create a new branch. | ||
git ls-remote --exit-code --heads $RemoteName $BranchName | ||
if ($LASTEXITCODE -eq 0) { | ||
Write-Host "git fetch $RemoteName $BranchName" | ||
git fetch $RemoteName $BranchName | ||
Write-Host "git checkout $BranchName." | ||
git checkout $BranchName | ||
} else { | ||
Write-Host "git checkout -b $BranchName." | ||
git checkout -b $BranchName | ||
} | ||
displayName: Checkout daily docs branch if it exists | ||
workingDirectory: $(DocRepoLocation) | ||
# If NOT performing a daily docs build, set the $(TargetBranchName) to the | ||
# default branch of the documentation repository. | ||
- ${{ if ne(parameters.DailyDocsBuild, 'true') }}: | ||
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml | ||
parameters: | ||
WorkingDirectory: $(DocRepoLocation) | ||
DefaultBranchVariableName: TargetBranchName | ||
|
||
- pwsh: | | ||
$packageInfoJson = '${{ convertToJson(parameters.PackageInfoLocations) }}'.Trim('"') | ||
$packageInfoLocations = ConvertFrom-Json $packageInfoJson | ||
${{ parameters.ScriptDirectory }}/Update-DocsMsMetadata.ps1 ` | ||
-PackageInfoJsonLocations $packageInfoLocations ` | ||
-DocRepoLocation "$(DocRepoLocation)" ` | ||
-Language '${{parameters.Language}}' ` | ||
-RepoId '${{ parameters.RepoId }}' | ||
displayName: Apply Documentation Updates | ||
|
||
- template: /eng/common/pipelines/templates/steps/git-push-changes.yml | ||
parameters: | ||
BaseRepoBranch: $(TargetBranchName) | ||
BaseRepoOwner: ${{ parameters.TargetDocRepoOwner }} | ||
CommitMsg: "Update docs metadata" | ||
TargetRepoName: ${{ parameters.TargetDocRepoName }} | ||
TargetRepoOwner: ${{ parameters.TargetDocRepoOwner }} | ||
WorkingDirectory: $(DocRepoLocation) | ||
ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.