1+ # capture-openapi.yml
12# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
23# The following template creates multiple artifacts from a matrix, this is the intended behavior to follow the same workflow before the governance migration
34
2122 persistCredentials : true
2223
2324 - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
25+
2426 - pwsh : |
2527 $dirPath = "./conversion-settings"
2628 $endpoint = "${{ parameters.endpoint }}"
3739 Write-Host "##vso[task.setvariable variable=targets;isOutput=true]$json"
3840 name: setTargets
3941 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
42+
4043 - script : echo $(setTargets.targets)
4144 displayName : " Print settings"
45+
4246- job : convert_openapi
4347 dependsOn : get_conversion_settings
4448 displayName : Convert
@@ -58,13 +62,12 @@ jobs:
5862 persistCredentials : true
5963
6064 - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
61-
6265 # required for the hidi to run
6366 - template : /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
6467 parameters :
6568 version : ' 8.x'
6669
67- # required for the hidi installation validation
70+ # required for the hidi installation validation
6871 - template : /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
6972 parameters :
7073 version : ' 9.x'
7881 displayName: ensure the generation happens from master latest
7982 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
8083
81- - pwsh : ' $(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"'
82- displayName : ' update ${{ parameters.endpoint }} open API description'
84+ - pwsh : |
85+ Write-Host "`ngit status before generation:"
86+ git status
87+ $(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"
88+ Write-Host "`ngit status after generation:"
89+ git status
90+ displayName: 'generate ${{ parameters.endpoint }} open API description'
8391 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
8492
8593 # publish metadata as an artifact
@@ -88,16 +96,16 @@ jobs:
8896 sourceFolder : ${{ parameters.outputPath }}
8997 contents : ' **/$(Name).yaml'
9098 targetFolder : ' $(Build.ArtifactStagingDirectory)/$(Name)'
91- displayName : Copy generated metadata
99+ displayName : Copy generated OpenAPI yaml file to ArtifactStagingDirectory
100+
92101 - pwsh : |
93102 ./scripts/run-openapi-validation.ps1 -repoDirectory (Get-Location).Path -version "${{ parameters.endpoint }}" -platformName "$(Name)"
94- displayName: ensure that OpenAPI docs can be parsed
103+ displayName: Validate that OpenAPI docs can be parsed
95104 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
96105
97-
98106 - job : publish_openapi
99107 dependsOn : convert_openapi
100- displayName : Publish
108+ displayName : Publish OpenAPI files
101109 # # If there's new settings added please add them here too
102110 templateContext :
103111 inputs :
@@ -123,35 +131,61 @@ jobs:
123131 displayName : checkout generator
124132 fetchDepth : 1
125133 persistCredentials : true
126- # Copy files from the maxtrix artifacts to a single folder
134+
135+ # Note that msgraph-metadata repo has detached HEAD
136+ - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
137+
138+ - template : /.azure-pipelines/generation-templates/set-user-config.yml@self
139+
140+ # Copy OpenAPI files from the matrix artifacts to the ArtifactStagingDirectory
141+ # This is used for library generation later
127142 - task : CopyFiles@2
128143 inputs :
129144 sourceFolder : ' $(Build.SourcesDirectory)/artifacts'
130145 contents : ' **/*.yaml'
131146 targetFolder : ' $(Build.ArtifactStagingDirectory)'
132- displayName : Copy artifact metadata
133- # Copy files from the target path where artifacts should be downloaded
147+ displayName : Copy OpenAPI input artifacts to artifact staging directory
148+
149+ # Copy OpenAPI files from ArtifactStagingDirectory to local msgraph-metadata repo
134150 - task : CopyFiles@2
135151 inputs :
136152 sourceFolder : ' $(Build.ArtifactStagingDirectory)'
137153 contents : ' **/*.yaml'
138154 targetFolder : ' $(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
139- displayName : Copy downloaded metadata
155+ overwrite : true
156+ displayName : Copy OpenAPI files to local msgraph-metadata repo
140157
141- # publish metadata as an artifact
142- - task : CopyFiles@2
143- inputs :
144- sourceFolder : ${{ parameters.outputPath }}
145- contents : ' **/*.yaml'
146- targetFolder : ' $(Build.ArtifactStagingDirectory)'
147- displayName : Copy downloaded metadata
148- - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
149- - template : /.azure-pipelines/generation-templates/set-user-config.yml@self
158+ # Push changes to msgraph-metadata repo
150159 - pwsh : ' $(scriptsDirectory)/git-push-cleanmetadata.ps1'
151-
152- displayName : push clean ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
160+ displayName : Publish ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
153161 env :
162+ CreateOpenAPIPR : True
154163 EndpointVersion : ${{ parameters.endpoint }}
155164 PublishChanges : $(publishChanges)
156165 workingDirectory : ' $(Build.SourcesDirectory)/msgraph-metadata'
157166 enabled : true
167+
168+
169+ # Create PR - note that this PR is not used for gating. It's just for discovery purposes.
170+ # Library generation PRs will still be created based on the OpenAPI files.
171+
172+ - task : AzureKeyVault@2
173+ displayName : " Azure Key Vault: Get Secrets"
174+ inputs :
175+ azureSubscription : " Federated AKV Managed Identity Connection"
176+ KeyVaultName : akv-prod-eastus
177+ SecretsFilter : " microsoft-graph-devx-bot-appid,microsoft-graph-devx-bot-privatekey"
178+
179+ - pwsh : ' $(scriptsDirectory)/create-pull-request.ps1'
180+ displayName : ' Create Pull Request for the generated OpenAPI files for msgraph-metadata'
181+ env :
182+ BaseBranch : master
183+ GeneratePullRequest : true
184+ GhAppId : $(microsoft-graph-devx-bot-appid)
185+ GhAppKey : $(microsoft-graph-devx-bot-privatekey)
186+ OverrideSkipCI : false
187+ RepoName : ' microsoftgraph/msgraph-metadata'
188+ ScriptsDirectory : $(scriptsDirectory)
189+ # Version is intentionally left empty for OpenAPI PRs as versioning is not applicable in this context.
190+ Version : ' '
191+ workingDirectory : ' $(Build.SourcesDirectory)/msgraph-metadata'
0 commit comments