Skip to content

Commit cea9686

Browse files
committed
Push SDK build artifacts to generation branch
1 parent 8f8f2b6 commit cea9686

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.azure-pipelines/weekly-preview-generation.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ parameters:
1010
- name: BaseBranch
1111
displayName: Base Branch
1212
default: features/2.0
13+
- name: GenerationBranch
14+
displayName: Generation branch
15+
default: v2/generation
1316
- name: SkipForceRefresh
1417
displayName: Skip Force Refresh
1518
default: false
@@ -34,6 +37,7 @@ parameters:
3437
variables:
3538
Branch: "WeeklyPreviewRefresh"
3639
BaseBranch: ${{ parameters.BaseBranch }}
40+
GenerationBranch: ${{ parameters.GenerationBranch }}
3741
BuildAgent: ${{ parameters.BuildAgent }}
3842
SkipForceRefresh: ${{ parameters.SkipForceRefresh }}
3943

@@ -116,3 +120,40 @@ jobs:
116120
TargetBranch: $(WeeklyBranch)
117121
Title: "[v2] Weekly OpenApiDocs Refresh"
118122
Body: "This pull request was automatically created by Azure Pipelines. **Important** Check for unexpected deletions or changes in this PR."
123+
# Push SDK artifacts to generation branch.
124+
- task: PowerShell@2
125+
name: "ComputeGenerationBranch"
126+
displayName: "Compute weekly generation branch name"
127+
inputs:
128+
targetType: inline
129+
script: |
130+
$branch = "{0}/{1}" -f "WeeklyGeneration", (Get-Date -Format yyyyMMddHHmm)
131+
Write-Host "##vso[task.setvariable variable=WeeklyGenerationBranch;isOutput=true]$branch"
132+
- task: Bash@3
133+
displayName: "Create weekly generation branch"
134+
inputs:
135+
targetType: inline
136+
script: |
137+
git status
138+
git branch $(ComputeGenerationBranch.WeeklyGenerationBranch)
139+
git checkout $(ComputeGenerationBranch.WeeklyGenerationBranch)
140+
git status
141+
- task: Bash@3
142+
displayName: Commit Generated SDK artifacts
143+
enabled: true
144+
env:
145+
GITHUB_TOKEN: $(GITHUB_TOKEN)
146+
inputs:
147+
targetType: inline
148+
script: |
149+
git add .
150+
git commit -m 'Adds generated module artifacts'
151+
git push "https://$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git"
152+
git status
153+
- ${{ if eq(parameters.CreatePullRequest, true) }}:
154+
- template: common-templates/create-pr.yml
155+
parameters:
156+
BaseBranch: $(GenerationBranch)
157+
TargetBranch: $(ComputeGenerationBranch.WeeklyGenerationBranch)
158+
Title: "[v2] Weekly Generated Module Artifacts"
159+
Body: "This pull request was automatically created by Azure Pipelines. **Important** Check for unexpected deletions or changes in this PR."

tools/BuildModule.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ if ($ModuleFullName -ne "Microsoft.Graph.Authentication") {
4949
Write-Debug "Failed to build '$ModuleFullName' module."
5050
exit $lastexitcode
5151
}
52+
53+
# Move generated docs from export folder to root of docs folder.
54+
$DocsPath = Join-Path $ModuleSrc "docs"
55+
$DocsExportPath = Join-Path $DocsPath "exports"
56+
Write-Debug "Moving generated docs from '$DocsExportPath' to '$DocsPath'..."
57+
if (Test-Path $DocsExportPath){
58+
$DocsExportFiles = Get-ChildItem $DocsExportPath -Recurse
59+
foreach ($docFile in $DocsExportFiles) {
60+
$newPath = Join-Path $DocsPath $docFile.Name
61+
Move-Item $docFile.FullName $newPath -Force
62+
}
63+
Write-Debug "Cleaning '$DocsExportPath'..."
64+
Remove-Item $DocsExportPath -Force -Recurse
65+
}
5266
}
5367

5468
# Lock module GUID. See https://github.com/Azure/autorest.powershell/issues/981.

0 commit comments

Comments
 (0)