File: update-docsms-metadata.yml

package info (click to toggle)
python-azure 20251014%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 766,472 kB
  • sloc: python: 6,314,744; ansic: 804; javascript: 287; makefile: 198; sh: 198; xml: 109
file content (103 lines) | stat: -rw-r--r-- 4,129 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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:
      - '**'
  - name: PackageSourceOverride
    type: string
    default: ''
steps:
  - ${{ if eq(length(parameters.PackageInfoLocations), 0) }}:
    - pwsh: |
        Write-Host "Skipping DocsMS Update because package list was empty."
      displayName: Skip DocsMS Update
  - ${{ else }}:
    - 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:
        SkipCheckoutNone: 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('"').Replace("\\", "/")
        # Without -NoEnumerate, a single element array[T] gets unwrapped as a single item T.
        $packageInfoLocations = ConvertFrom-Json $packageInfoJson -NoEnumerate
        ${{ parameters.ScriptDirectory }}/Update-DocsMsMetadata.ps1 `
          -PackageInfoJsonLocations $packageInfoLocations `
          -DocRepoLocation "$(DocRepoLocation)" `
          -Language '${{parameters.Language}}' `
          -RepoId '${{ parameters.RepoId }}' `
          -PackageSourceOverride '${{ parameters.PackageSourceOverride }}'
      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 }}