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