forked from Azure/azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appveyor-dev.yml
87 lines (81 loc) · 3.77 KB
/
appveyor-dev.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
branches:
only:
- dev
init:
- git config --global core.autocrlf false
environment:
PYTHON: "C:\\Python35"
access_token:
secure: VMFbecLLHzDq/09YDPbcM0VDDSwwgY57vr5GXK6cZZ4Ti/Xs5RZoylzV8MMr1350
extension_repo: "https://github.com/Azure/azure-cli-extensions"
extension_branch: "master"
extentsion_folder: "_ext"
install:
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
- python scripts/dev_setup.py
- python -m pip install sphinx==1.5.6
build_script:
- ps: |
$docSourceRaw = Get-Content -Raw -Path "$env:APPVEYOR_BUILD_FOLDER\doc\sphinx\azhelpgen\doc_source_map.json" | ConvertFrom-Json
$docFiles = $docSourceRaw | Get-Member -type NoteProperty | %{ $docSourceRaw."$($_.Name)" }
$docFiles = $docFiles | select -Unique
$fileCommitMap = @{}
foreach($file in $docFiles)
{
$commitId = (git rev-list -1 HEAD $file)
if($commitId -match '^[0-9a-f]{40}$')
{
$date = Get-Date -Date (git log --pretty=format:%cd -n 1 --date=iso $file)
$date = $date.ToUniversalTime()
$date = Get-Date $date -format G
$fileCommitMap[$file] = @{}
$fileCommitMap[$file]["commit"] = $commitId
$fileCommitMap[$file]["date"] = $date
}
else
{
Write-Host -ForegroundColor Red "Failed to get commit id for $file"
$host.SetShouldExit(-1)
}
}
$fileCommitMap | ConvertTo-Json | Out-File "$env:APPVEYOR_BUILD_FOLDER\doc\sphinx\doc_commit_map.json"
- cd doc\sphinx
- make xmlwithversion
- git clone --depth 5 -q --branch=%extension_branch% %extension_repo% %TEMP%\azure-cli-extensions
- cd %TEMP%\azure-cli-extensions
- virtualenv --no-site-packages venv
- .\venv\Scripts\activate
- pip install azure-cli sphinx==1.7.0
- mkdir xmls
- set AZ_EXT_REF_DOC_OUT_DIR=xmls
- python ./scripts/ci/index_ref_doc.py -v
- deactivate
- mkdir %TEMP%\azure-cli-xml2yml
- cd %TEMP%\azure-cli-xml2yml
- nuget install azure.cli.doc.xml2yml -Source https://ci.appveyor.com/nuget/azure-docs-cli-pre-process
- cd azure.cli.doc.xml2yml*\tools
- AzCliDocPreprocessor -s "%APPVEYOR_BUILD_FOLDER%\doc\sphinx\_build\xml" -x "%TEMP%\azure-cli-extensions\xmls" -d "%TEMP%\azure-cli-xml2yml\yml-output" -r "https://github.com/%APPVEYOR_REPO_NAME%" -b "%APPVEYOR_REPO_BRANCH%" -c "%APPVEYOR_BUILD_FOLDER%\doc\sphinx\doc_commit_map.json" -v 1
artifacts:
- path: doc\sphinx\_build
on_success:
- git config --global credential.helper store
- ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):[email protected]`n"
- git config --global user.email "%GIT_USER_EMAIL%"
- git config --global user.name "%GIT_USER_NAME%"
- git clone --depth 5 -q --branch=%TARGET_BRANCH% %GIT_CONTENT_REPO_URL% %TEMP%\azure-cli-content
- ps: |
$folders = Get-ChildItem -Path "$env:TEMP\azure-cli-content" -Directory
ForEach($folder in $folders)
{
$folderPath = [System.IO.Path]::Combine("$env:TEMP\azure-cli-content", $folder)
$subFolders = Get-ChildItem -Path $folderPath -Directory -Name
if ($subFolders -contains "$env:YML_OUTPUT_FOLDER")
{
$docsRefAutogenFolder = [System.IO.Path]::Combine($folderPath, "$env:YML_OUTPUT_FOLDER")
Get-ChildItem -Path $docsRefAutogenFolder | Remove-Item -Force -Recurse
}
}
- cd %TEMP%\azure-cli-content
- SETLOCAL EnableDelayedExpansion & robocopy %TEMP%\azure-cli-xml2yml\yml-output %TEMP%\azure-cli-content /e & IF !ERRORLEVEL! EQU 1 (exit 0) ELSE (IF !ERRORLEVEL! EQU 3 (exit 0) ELSE (exit 1))
- git add -A
- git diff --quiet --exit-code --cached || git commit -m "Update Document Content" && git push origin %TARGET_BRANCH% && appveyor AddMessage "Document Updated"