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.

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