forked from Azure/azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appveyor.yml
65 lines (59 loc) · 2.99 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
60
61
62
63
64
65
branches:
only:
- master
init:
- git config --global core.autocrlf false
environment:
PYTHON: "C:\\Python35"
access_token:
secure: VMFbecLLHzDq/09YDPbcM0VDDSwwgY57vr5GXK6cZZ4Ti/Xs5RZoylzV8MMr1350
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 xml
- 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\ind.xml" -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
- if exist %TEMP%\azure-cli-content\%YML_OUTPUT_FOLDER% ((cd %TEMP%\azure-cli-content\%YML_OUTPUT_FOLDER%) & (del %FILES_TO_DELETE% /f /q) & (for /d %%p IN (*) do rmdir "%%p" /s /q))
- cd %TEMP%\azure-cli-content
- SETLOCAL EnableDelayedExpansion & robocopy %TEMP%\azure-cli-xml2yml\yml-output %TEMP%\azure-cli-content\%YML_OUTPUT_FOLDER% /e & IF !ERRORLEVEL! EQU 1 (exit 0) ELSE (IF !ERRORLEVEL! EQU 3 (exit 0) ELSE (exit 1))
- ps: .\merge-toc.ps1 "$env:YML_OUTPUT_FOLDER" "$env:CONCEPTUAL_DOC_FOLDER"
- git add -A
- git diff --quiet --exit-code --cached || git commit -m "Update Document Content" && git push origin %TARGET_BRANCH% && appveyor AddMessage "Document Updated"