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.

98 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: Set branch name variable
  26. shell: powershell
  27. run: |
  28. $env:BRANCH_NAME = (git rev-parse --abbrev-ref $env:GITHUB_REF) -join ""
  29. echo $env:BRANCH_NAME
  30. - name: Locate MSBuild
  31. uses: warrenbuckley/Setup-MSBuild@v1
  32. - name: Setup Nuget
  33. uses: warrenbuckley/Setup-Nuget@v1
  34. - name: Nuget Restore
  35. run: nuget restore
  36. - name: Install DocFX
  37. uses: crazy-max/ghaction-chocolatey@v1
  38. with:
  39. args: install docfx -y
  40. - name: Build docs
  41. shell: powershell
  42. working-directory: ./docs
  43. run: |
  44. Add-Content link_branch.json "{`"_gitContribute`":{`"sourceBranch`":`"$env:GITHUB_SHA`",`"apiSpecFolder`":`"docs/override`"}}"
  45. powershell .\build.ps1
  46. if ($lastexitcode -ne 0){
  47. throw [System.Exception] "docfx build failed with exit code $lastexitcode."
  48. }
  49. echo $env:BRANCH_NAME
  50. - name: Checkout current pages
  51. uses: actions/checkout@v2
  52. with:
  53. ref: gh-pages
  54. token: ${{ secrets.pagesCommitToken }}
  55. path: docs/${{ env.ORIGIN_SITE }}
  56. - name: Publish master site to GitHub pages
  57. shell: powershell
  58. working-directory: ./docs
  59. run: |
  60. Move-Item "$env:ORIGIN_SITE/.git" _site
  61. Move-Item "$env:ORIGIN_SITE/$env:TAGS_DIR" _site
  62. Move-Item "$env:ORIGIN_SITE/$env:BRANCH_DIR" _site
  63. cd _site
  64. git add -A 2>&1
  65. $srcMessage = (git show -s --format=%B $env:GITHUB_SHA) -join "`n"
  66. git commit -q -a -m "Generated Docs -- $srcMessage"
  67. git push -q origin gh-pages
  68. if: env.BRANCH_NAME == 'master'
  69. - name: Publish branch site to GitHub pages
  70. shell: powershell
  71. working-directory: ./docs/${{ env.ORIGIN_SITE }}
  72. run: |
  73. if (-Not (Test-Path $env:BRANCH_DIR))
  74. { New-Item -ItemType directory -Path $env:BRANCH_DIR }
  75. $branchPath = "$env:BRANCH_DIR/$env:BRANCH_NAME"
  76. if (Test-Path $branchPath) {
  77. # force remove it
  78. Get-ChildItem -Path $branchPath -Recurse | Remove-Item -Force -Recurse
  79. Remove-Item $branchPath -Force
  80. }
  81. # move generated into place
  82. Move-Item ../_site $branchPath
  83. git add -A 2>&1
  84. $srcMessage = (git show -s --format=%B $env:GITHUB_SHA) -join "`n"
  85. git commit -q -a -m "Generated Docs ($env:BRANCH_NAME) -- $srcMessage"
  86. git push -q origin gh-pages
  87. if: env.BRANCH_NAME != 'master'