Skip to content

Commit 49adbf4

Browse files
authored
Merge pull request Azure#3106 from Visual-Studio-China/dev
[Hold]: Add CI to sync docs from source code repo to content repo
2 parents a364bc2 + 0b5e9d1 commit 49adbf4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

appveyor.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
branches:
2+
only:
3+
- master
4+
environment:
5+
github_access_token:
6+
secure: VMFbecLLHzDq/09YDPbcM0VDDSwwgY57vr5GXK6cZZ4Ti/Xs5RZoylzV8MMr1350
7+
8+
build_script:
9+
- ps: |
10+
$ErrorActionPreference = "Stop"
11+
$response = Invoke-WebRequest ("https://api.github.com/repos/" + $env:APPVEYOR_REPO_NAME + "/releases/tags/" + $env:APPVEYOR_REPO_TAG_NAME) -Timeout 10
12+
if($response -ne $null -and $response.StatusCode -ne 200)
13+
{
14+
$host.SetShouldExit(1)
15+
}
16+
17+
$unzip_path = "C:\projects\azure-powershell-release"
18+
$unzip_file = $unzip_path + "zip"
19+
Invoke-WebRequest ($response.Content | ConvertFrom-Json).zipball_url -OutFile $unzip_file
20+
7z x $unzip_file -o"$unzip_path"
21+
$src = Join-Path (ls $unzip_path -dir | select -First 1 | % { $_.FullName }) "src"
22+
$global:output = Join-Path $unzip_path "output"
23+
ni $global:output -type dir
24+
$pattern = "\d(.\d)*"
25+
26+
foreach($folder in (ls $src -dir))
27+
{
28+
foreach($module in (ls $folder.FullName -dir | % { $_.FullName }))
29+
{
30+
# find out docs in help folder and version in .psd1 file
31+
$help = ls $module -dir -Recurse | ? { $_.Name -eq "help" } | select -First 1 | % { $_.FullName }
32+
if($help -eq $null)
33+
{
34+
continue
35+
}
36+
$psd1= ls $module | ? { $_.extension -eq ".psd1" } | select -First 1 | % { $_.FullName }
37+
if($psd1 -eq $null)
38+
{
39+
continue
40+
}
41+
if((gc $psd1 | Out-String) -notmatch "ModuleVersion\s*=\s*$pattern")
42+
{
43+
continue
44+
}
45+
robocopy $help "*.md" (Join-Path $global:output $folder | Join-Path -ChildPath (gi $psd1).BaseName | Join-Path -ChildPath ("v" + ($matches[0] -match $pattern)))
46+
}
47+
}
48+
test: off
49+
shallow_clone: true
50+
on_success:
51+
- git clone -q --branch=%target_branch% %content_repo% %TEMP%\Azure
52+
- cd %TEMP%\Azure
53+
- ps: ls $global:output -dir | % { copy $_.FullName (ls -dir | select -First 1) -Recurse -Force }
54+
- git config --global credential.helper store
55+
- ps: ac "$env:USERPROFILE\.git-credentials" "https://$($env:github_access_token):[email protected]`n"
56+
- git config --global user.email %email%
57+
- git config --global user.name %name%
58+
- git add -A
59+
- git diff --quiet --exit-code --cached || git commit -m "Sync docs from source code repo to content repo." && git push origin %target_branch% && appveyor AddMessage "Content Updated"

0 commit comments

Comments
 (0)