Skip to content

Commit 11a16eb

Browse files
committed
ci: add PR for OpenAPI files
1 parent a4fdada commit 11a16eb

File tree

4 files changed

+55
-10
lines changed

4 files changed

+55
-10
lines changed

.azure-pipelines/generation-templates/capture-metadata.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ steps:
166166

167167
# Checkin clean metadata into metadata repo or make it an artifact.
168168
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
169-
170-
displayName: push clean ${{ parameters.endpoint }} metadata to msgraph-metadata repo
169+
displayName: push clean ${{ parameters.endpoint }} CSDL metadata to msgraph-metadata repo
171170
env:
171+
CreatePR: False
172172
EndpointVersion: ${{ parameters.endpoint }}
173173
PublishChanges: $(publishChanges)
174174
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'

.azure-pipelines/generation-templates/capture-openapi.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,31 @@ jobs:
159159
- pwsh: '$(scriptsDirectory)/git-push-cleanmetadata.ps1'
160160
displayName: push clean ${{ parameters.endpoint }} OpenAPI description to msgraph-metadata repo
161161
env:
162+
CreatePR: True
162163
EndpointVersion: ${{ parameters.endpoint }}
163164
PublishChanges: $(publishChanges)
164165
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'
165166
enabled: true
167+
168+
# Create PR - note that this PR is not used for gating. It's just for discovery purposes. Library generation PRs will still
169+
# be created based on the OpenAPI files.
170+
171+
- task: AzureKeyVault@2
172+
displayName: "Azure Key Vault: Get Secrets"
173+
inputs:
174+
azureSubscription: "Federated AKV Managed Identity Connection"
175+
KeyVaultName: akv-prod-eastus
176+
SecretsFilter: "microsoft-graph-devx-bot-appid,microsoft-graph-devx-bot-privatekey"
177+
178+
- pwsh: '$(scriptsDirectory)/create-pull-request.ps1'
179+
displayName: 'Create Pull Request for the generated OpenAPI files for msgraph-metadata'
180+
env:
181+
BaseBranch: master
182+
GeneratePullRequest: true
183+
GhAppId: $(microsoft-graph-devx-bot-appid)
184+
GhAppKey: $(microsoft-graph-devx-bot-privatekey)
185+
OverrideSkipCI: false
186+
RepoName: 'microsoftgraph/msgraph-metadata'
187+
ScriptsDirectory: $(scriptsDirectory)
188+
Version: ''
189+
workingDirectory: '$(Build.SourcesDirectory)/msgraph-metadata'

scripts/create-pull-request.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ if (($env:GeneratePullRequest -eq $False)) { # Skip CI if manually running this
99
return;
1010
}
1111

12+
$version = $env:Version
13+
1214
# Special case for beta typings as it uses a non-conforming preview versioning.
1315
if ($env:RepoName.Contains("msgraph-beta-typescript-typings"))
1416
{
@@ -18,7 +20,6 @@ else {
1820
$title = "Generated $version models and request builders"
1921
}
2022

21-
$version = $env:Version
2223
$body = ":bangbang:**_Important_**:bangbang: <br> Check for unexpected deletions or changes in this PR and ensure relevant CI checks are passing. <br><br> **Note:** This pull request was automatically created by Azure pipelines."
2324
$baseBranchParameter = ""
2425

scripts/git-push-cleanmetadata.ps1

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the
33
# project root for license information.
44

5+
# Referenced by:
6+
# capture-metadata.yml
7+
# capture-openapi.yml
8+
59
# This script stashes any changes, checks out the latest master branch, applies the stashed changes, commits, and
610
# pushes the changes back to the remote repository.
711

@@ -31,6 +35,12 @@ git stash pop | Write-Host -ForegroundColor Yellow
3135
Write-Host "`nGet status:" -ForegroundColor Green
3236
git status | Write-Host -ForegroundColor Yellow
3337

38+
if ($env:CreatePR -eq $True)
39+
{
40+
Write-Host "`nCreate branch: $env:BUILD_BUILDID/updateOpenAPI" -ForegroundColor Green
41+
git checkout -B $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
42+
}
43+
3444
Write-Host "`nStaging clean $env:EndpointVersion metadata files....." -ForegroundColor Green
3545
git add . | Write-Host -ForegroundColor Yellow
3646

@@ -51,11 +61,21 @@ else
5161
Write-Host "`nGet status:" -ForegroundColor Green
5262
git status | Write-Host -ForegroundColor Yellow
5363

54-
Write-Host "`nRunning: git pull origin master --rebase..." -ForegroundColor Green
55-
# sync branch before pushing
56-
# this is especially important while running v1 and beta in parallel
57-
# and one process goes out of sync because of the other's check-in
58-
git pull origin master --rebase | Write-Host -ForegroundColor Yellow
64+
if ($env:CreatePR -eq $True)
65+
{
66+
Write-Host "`nPushing branch for PR creation" -ForegroundColor Green
67+
68+
Write-Host "`ngit push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI:" -ForegroundColor Green
69+
git push --set-upstream origin $env:BUILD_BUILDID/updateOpenAPI | Write-Host -ForegroundColor Yellow
70+
}
71+
else # original behavior: push to master
72+
{
73+
Write-Host "`nRunning: git pull origin master --rebase..." -ForegroundColor Green
74+
# sync branch before pushing
75+
# this is especially important while running v1 and beta in parallel
76+
# and one process goes out of sync because of the other's check-in
77+
git pull origin master --rebase | Write-Host -ForegroundColor Yellow
5978

60-
Write-Host "`nRunning: git push --set-upstream origin master ..." -ForegroundColor Green
61-
git push --set-upstream origin master | Write-Host -ForegroundColor Yellow
79+
Write-Host "`nRunning: git push --set-upstream origin master ..." -ForegroundColor Green
80+
git push --set-upstream origin master | Write-Host -ForegroundColor Yellow
81+
}

0 commit comments

Comments
 (0)