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