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.

79 lines
2.5 KiB

4 years ago
4 years ago
  1. name: Tag Docs
  2. on:
  3. release:
  4. types: [created]
  5. jobs:
  6. docs:
  7. env:
  8. ORIGIN_SITE: _origin_site
  9. TAGS_DIR: tags
  10. BRANCH_DIR: branch
  11. name: Generate docs
  12. runs-on: windows-latest
  13. steps:
  14. - name: Configure git
  15. shell: powershell
  16. run: |
  17. git config --global core.autocrlf true
  18. git config --global user.email (($env:GITHUB_ACTOR,"@users.noreply.github.com") -join "")
  19. git config --global user.name $env:GITHUB_ACTOR
  20. - name: Checkout branch
  21. uses: actions/checkout@v2
  22. - name: Checkout submodules
  23. run: git submodule update --init --recursive
  24. - name: Locate MSBuild
  25. uses: warrenbuckley/Setup-MSBuild@v1
  26. - name: Setup Nuget
  27. uses: warrenbuckley/Setup-Nuget@v1
  28. - name: Nuget Restore
  29. run: nuget restore
  30. - name: Install DocFX
  31. uses: crazy-max/ghaction-chocolatey@v1
  32. with:
  33. args: install docfx --version 2.48 -y
  34. - name: Checkout current pages
  35. uses: actions/checkout@v2
  36. with:
  37. ref: gh-pages
  38. token: ${{ secrets.pagesCommitToken }}
  39. path: docs/${{ env.ORIGIN_SITE }}
  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. - name: Publish tag site to GitHub pages
  50. shell: powershell
  51. working-directory: ./docs
  52. run: |
  53. $ErrorActionPreference = "Continue"
  54. $tagName = (git rev-parse --abbrev-ref=loose $env:GITHUB_REF) -join ""
  55. cd $env:ORIGIN_SITE
  56. if (-Not (Test-Path $env:TAGS_DIR)) {
  57. New-Item -ItemType directory -Path $env:TAGS_DIR
  58. }
  59. $tagPath = "$env:TAGS_DIR/$tagName"
  60. if (Test-Path $tagPath) {
  61. # force remove it
  62. Get-ChildItem -Path $tagPath -Recurse | Remove-Item -Force -Recurse
  63. Remove-Item $tagPath -Force
  64. }
  65. # move generated into place
  66. Move-Item ../_site $tagPath
  67. git add -A 2>&1
  68. git commit -q -a -m "Saved tag $tagName"
  69. git push -q origin gh-pages