You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.3 KiB

  1. name: Routine Docs
  2. on:
  3. push:
  4. branches-ignore:
  5. - gh-pages
  6. jobs:
  7. docs:
  8. env:
  9. ORIGIN_SITE: _origin_site
  10. TAGS_DIR: tags
  11. BRANCH_DIR: branch
  12. name: Generate docs
  13. runs-on: windows-latest
  14. steps:
  15. - name: Configure Git
  16. shell: powershell
  17. run: |
  18. git config --global core.autocrlf true
  19. git config --global user.email (($env:GITHUB_ACTOR,"@users.noreply.github.com") -join "")
  20. git config --global user.name $env:GITHUB_ACTOR
  21. - name: Checkout branch
  22. uses: actions/checkout@v2
  23. - name: Checkout submodules
  24. run: git submodule update --init --recursive
  25. - name: Locate MSBuild
  26. uses: warrenbuckley/Setup-MSBuild@v1
  27. - name: Setup Nuget
  28. uses: warrenbuckley/Setup-Nuget@v1
  29. - name: Nuget Restore
  30. run: nuget restore
  31. - name: Install DocFX
  32. uses: crazy-max/ghaction-chocolatey@v1
  33. with:
  34. args: install docfx -y
  35. - name: Build docs
  36. shell: powershell
  37. working-directory: ./docs
  38. run: |
  39. Add-Content link_branch.json "{`"_gitContribute`":{`"sourceBranch`":`"$env:GITHUB_SHA`",`"apiSpecFolder`":`"docs/override`"}}"
  40. powershell .\build.ps1
  41. if ($lastexitcode -ne 0){
  42. throw [System.Exception] "docfx build failed with exit code $lastexitcode."
  43. }
  44. - name: Checkout current pages
  45. uses: actions/checkout@v2
  46. with:
  47. ref: gh-pages
  48. token: ${{ secrets.pagesCommitToken }}
  49. path: docs/${{ env.ORIGIN_SITE }}
  50. - name: Publish master site to GitHub pages
  51. shell: powershell
  52. working-directory: ./docs
  53. run: |
  54. Move-Item "$env:ORIGIN_SITE/.git" _site
  55. Move-Item "$env:ORIGIN_SITE/$env:TAGS_DIR" _site
  56. Move-Item "$env:ORIGIN_SITE/$env:BRANCH_DIR" _site
  57. cd _site
  58. $ErrorActionPreference = "SilentlyContinue"
  59. git add -A 2>&1
  60. $srcMessage = (git show -s --format=%B $env:GITHUB_SHA) -join "`n"
  61. git commit -q -a -m "Generated Docs -- $srcMessage"
  62. git push -q origin gh-pages
  63. if: github.ref == 'refs/heads/master'
  64. - name: Publish branch site to GitHub pages
  65. shell: powershell
  66. working-directory: ./docs/${{ env.ORIGIN_SITE }}
  67. run: |
  68. if (-Not (Test-Path $env:BRANCH_DIR))
  69. { New-Item -ItemType directory -Path $env:BRANCH_DIR }
  70. $branchName = (git rev-parse --abbrev-ref $env:GITHUB_REF) -join ""
  71. $branchPath = "$env:BRANCH_DIR/$branchName"
  72. if (Test-Path $branchPath) {
  73. # force remove it
  74. Get-ChildItem -Path $branchPath -Recurse | Remove-Item -Force -Recurse
  75. Remove-Item $branchPath -Force
  76. }
  77. # move generated into place
  78. Move-Item ../_site $branchPath
  79. $ErrorActionPreference = "SilentlyContinue"
  80. git add -A 2>&1
  81. $srcMessage = (git show -s --format=%B $env:GITHUB_SHA) -join "`n"
  82. git commit -q -a -m "Generated Docs ($branchName) -- $srcMessage"
  83. git push -q origin gh-pages
  84. if: github.ref != 'refs/heads/master'