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 xmlwithlatest - git config --global credential.helper store - ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`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 } } - 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" -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" -f "%TEMP%\azure-cli-content\TitleMapping.json" -v 1 artifacts: - path: doc\sphinx\_build on_success: - 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"