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
@@ -58,13 +59,12 @@ jobs:
5859 persistCredentials : true
5960
6061 - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
61-
6262 # required for the hidi to run
6363 - template : /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
6464 parameters :
6565 version : ' 8.x'
6666
67- # required for the hidi installation validation
67+ # required for the hidi installation validation
6868 - template : /.azure-pipelines/generation-templates/use-dotnet-sdk.yml@self
6969 parameters :
7070 version : ' 9.x'
7878 displayName: ensure the generation happens from master latest
7979 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
8080
81- - pwsh : ' $(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"'
82- displayName : ' update ${{ parameters.endpoint }} open API description'
81+ - pwsh : |
82+ Write-Host "`ngit status before generation:"
83+ git status
84+ $(scriptsDirectory)/generate-open-api.ps1 -endpointVersion ${{ parameters.endpoint }} -settings "$(conversionSettingsDirectory)/$(File)" -platformName "$(Name)"
85+ Write-Host "`ngit status after generation:"
86+ git status
87+ displayName: 'generate ${{ parameters.endpoint }} open API description'
8388 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
8489
8590 # publish metadata as an artifact
@@ -88,16 +93,16 @@ jobs:
8893 sourceFolder : ${{ parameters.outputPath }}
8994 contents : ' **/$(Name).yaml'
9095 targetFolder : ' $(Build.ArtifactStagingDirectory)/$(Name)'
91- displayName : Copy generated metadata
96+ displayName : Copy generated OpenAPI yaml file to ArtifactStagingDirectory
97+
9298 - pwsh : |
9399 ./scripts/run-openapi-validation.ps1 -repoDirectory (Get-Location).Path -version "${{ parameters.endpoint }}" -platformName "$(Name)"
94- displayName: ensure that OpenAPI docs can be parsed
100+ displayName: Validate that OpenAPI docs can be parsed
95101 workingDirectory: $(Build.SourcesDirectory)/msgraph-metadata
96102
97-
98103 - job : publish_openapi
99104 dependsOn : convert_openapi
100- displayName : Publish
105+ displayName : Publish OpenAPI files
101106 # # If there's new settings added please add them here too
102107 templateContext :
103108 inputs :
@@ -123,35 +128,61 @@ jobs:
123128 displayName : checkout generator
124129 fetchDepth : 1
125130 persistCredentials : true
126- # Copy files from the maxtrix artifacts to a single folder
131+
132+ # Note that msgraph-metadata repo has detached HEAD
133+ - template : /.azure-pipelines/generation-templates/checkout-metadata.yml@self
134+
135+ - template : /.azure-pipelines/generation-templates/set-user-config.yml@self
136+
137+ # Copy OpenAPI files from the matrix artifacts to the ArtifactStagingDirectory
138+ # This is used for library generation later
127139 - task : CopyFiles@2
128140 inputs :
129141 sourceFolder : ' $(Build.SourcesDirectory)/artifacts'
130142 contents : ' **/*.yaml'
131143 targetFolder : ' $(Build.ArtifactStagingDirectory)'
132- displayName : Copy artifact metadata
133- # Copy files from the target path where artifacts should be downloaded
144+ displayName : Copy OpenAPI input artifacts to artifact staging directory
145+
146+ # Copy OpenAPI files from ArtifactStagingDirectory to local msgraph-metadata repo
134147 - task : CopyFiles@2
135148 inputs :
136149 sourceFolder : ' $(Build.ArtifactStagingDirectory)'
137150 contents : ' **/*.yaml'
138151 targetFolder : ' $(Build.SourcesDirectory)/msgraph-metadata/openapi/${{ parameters.endpoint }}'
139- displayName : Copy downloaded metadata
152+ overwrite : true
153+ displayName : Copy OpenAPI files to local msgraph-metadata repo
140154
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
155+ # Push changes to msgraph-metadata repo
150156 - pwsh : ' $(scriptsDirectory)/git-push-cleanmetadata.ps1'
151-
152- displayName : push clean ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
157+ displayName : Publish ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
153158 env :
159+ CreateOpenAPIPR : True
154160 EndpointVersion : ${{ parameters.endpoint }}
155161 PublishChanges : $(publishChanges)
156162 workingDirectory : ' $(Build.SourcesDirectory)/msgraph-metadata'
157163 enabled : true
164+
165+
166+ # Create PR - note that this PR is not used for gating. It's just for discovery purposes.
167+ # Library generation PRs will still be created based on the OpenAPI files.
168+
169+ - task : AzureKeyVault@2
170+ displayName : " Azure Key Vault: Get Secrets"
171+ inputs :
172+ azureSubscription : " Federated AKV Managed Identity Connection"
173+ KeyVaultName : akv-prod-eastus
174+ SecretsFilter : " microsoft-graph-devx-bot-appid,microsoft-graph-devx-bot-privatekey"
175+
176+ - pwsh : ' $(scriptsDirectory)/create-pull-request.ps1'
177+ displayName : ' Create Pull Request for the generated OpenAPI files for msgraph-metadata'
178+ env :
179+ BaseBranch : master
180+ GeneratePullRequest : true
181+ GhAppId : $(microsoft-graph-devx-bot-appid)
182+ GhAppKey : $(microsoft-graph-devx-bot-privatekey)
183+ OverrideSkipCI : false
184+ RepoName : ' microsoftgraph/msgraph-metadata'
185+ ScriptsDirectory : $(scriptsDirectory)
186+ # Version is intentionally left empty for OpenAPI PRs as versioning is not applicable in this context.
187+ Version : ' '
188+ workingDirectory : ' $(Build.SourcesDirectory)/msgraph-metadata'
0 commit comments