name: Routine Docs
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- gh-pages
|
|
|
|
jobs:
|
|
docs:
|
|
env:
|
|
ORIGIN_SITE: _origin_site
|
|
TAGS_DIR: tags
|
|
BRANCH_DIR: branch
|
|
SOURCE_COMMIT: ${{ github.sha }}
|
|
SOURCE_REF: ${{ github.ref }}
|
|
name: Generate docs
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Configure Git
|
|
run:
|
|
- git config --global core.autocrlf true
|
|
- git config --global user.email ${{ github.actor }}@users.noreply.github.com
|
|
- git config --global user.name ${{ github.actor }}
|
|
- name: Checkout branch
|
|
uses: actions/checkout@v2
|
|
- name: Checkout submodules
|
|
run: git submodule update --init --recursive
|
|
- name: Locate MSBuild
|
|
uses: warrenbuckley/Setup-MSBuild@v1
|
|
- name: Setup Nuget
|
|
uses: warrenbuckley/Setup-Nuget@v1
|
|
- name: Nuget Restore
|
|
run: nuget restore
|
|
- name: Install DocFX
|
|
uses: crazy-max/ghaction-chocolatey@v1
|
|
with:
|
|
args: install docfx -y
|
|
- name: Build docs
|
|
shell: powershell
|
|
working-directory: ./docs
|
|
run: |
|
|
Add-Content link_branch.json "{`"_gitContribute`":{`"sourceBranch`":`"$env:SOURCE_COMMIT`",`"apiSpecFolder`":`"docs/override`"}}"
|
|
powershell .\build.ps1
|
|
if ($lastexitcode -ne 0){
|
|
throw [System.Exception] "docfx build failed with exit code $lastexitcode."
|
|
}
|
|
- name: Checkout current pages
|
|
uses: actions/checkout@v2
|
|
with:
|
|
ref: gh-pages
|
|
token: ${{ secrets.pagesCommitToken }}
|
|
path: docs/${{ env.ORIGIN_SITE }}
|
|
- name: Publish master site to GitHub pages
|
|
shell: powershell
|
|
working-directory: ./docs
|
|
run: |
|
|
Move-Item "$env:ORIGIN_SITE/.git" _site
|
|
Move-Item "$env:ORIGIN_SITE/$env:TAGS_DIR" _site
|
|
Move-Item "$env:ORIGIN_SITE/$env:BRANCH_DIR" _site
|
|
|
|
cd _site
|
|
git add -A 2>&1
|
|
|
|
$srcMessage = (git show -s --format=%B $env:SOURCE_COMMIT) -join "`n"
|
|
git commit -q -a -m "Generated Docs -- $srcMessage"
|
|
|
|
git push -q origin gh-pages
|
|
if: github.ref == 'master'
|
|
- name: Publish branch site to GitHub pages
|
|
shell: powershell
|
|
working-directory: ./docs/${{ env.ORIGIN_SITE }}
|
|
run: |
|
|
$branchPath = "$env:BRANCH_DIR/$env:SOURCE_REF"
|
|
|
|
# force remove it
|
|
Get-ChildItem -Path $branchPath -Recurse | Remove-Item -Force -Recurse
|
|
Remove-Item $branchPath -Force
|
|
|
|
# move generated into place
|
|
Move-Item ../_site $branchPath
|
|
|
|
git add -A 2>&1
|
|
|
|
$srcMessage = (git show -s --format=%B $env:SOURCE_COMMIT) -join "`n"
|
|
git commit -q -a -m "Generated Docs ($env:SOURCE_REF) -- $srcMessage"
|
|
|
|
git push -q origin gh-pages
|
|
if: github.ref != 'master'
|