Only run publish on commits to main #177
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Documentation | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Clone Repo | |
uses: actions/checkout@v1 | |
- name: Download DocFX | |
run: | | |
mkdir .tools/docfx | |
Invoke-WebRequest -Uri "https://github.com/dotnet/docfx/releases/download/v${env:DOCFXVERSION}/docfx.zip" -OutFile ".tools/docfx/docfx.zip" | |
[System.IO.Compression.ZipFile]::ExtractToDirectory(".tools/docfx/docfx.zip", ".tools/docfx" ) | |
env: | |
DOCFXVERSION: 2.59.4 | |
- name: Build Documentation | |
env: | |
DOCFX_SOURCE_BRANCH_NAME: main | |
run: | | |
.tools/docfx/docfx.exe docs/docfx.json | |
powershell -ExecutionPolicy ByPass -command "docs\FixApiRefLinks" -Path output\docs_site\api\ | |
- name: Publish Documentation | |
env: | |
ACCESS_TOKEN: ${{ secrets.GH_PAT }} | |
BRANCH: gh-pages | |
shell: cmd | |
run: | | |
cd output\docs_site | |
git init | |
git config --local user.name "%GITHUB_ACTOR%" | |
git config --local user.email "%GITHUB_ACTOR%@users.noreply.github.com" | |
git config --local core.autocrlf false | |
git add . | |
git commit -m "Auto-update doc from commit %GITHUB_SHA%" | |
git push --force https://%ACCESS_TOKEN%@github.com/%GITHUB_REPOSITORY%.git master:%BRANCH% | |
rmdir .git /S /Q | |