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.

75 lines
2.7 KiB

4 years ago
4 years ago
  1. name: Tag Docs
  2. on:
  3. release:
  4. types: [ "published" ]
  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: microsoft/[email protected]
  26. - name: Setup .NET Core
  27. uses: actions/setup-dotnet@v1
  28. with:
  29. # As usual, obtained from: https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/5.0/releases.json
  30. dotnet-version: "3.1.404" # since we now use this
  31. - name: Clear Nuget Cache
  32. run: dotnet nuget locals all --clear
  33. - name: Nuget Restore
  34. run: msbuild -t:Restore -m
  35. - name: Install DocFX
  36. uses: crazy-max/ghaction-chocolatey@v1
  37. with:
  38. args: install docfx -y
  39. - name: Checkout current pages
  40. uses: actions/checkout@v2
  41. with:
  42. ref: gh-pages
  43. token: ${{ secrets.pagesCommitToken }}
  44. path: docs/${{ env.ORIGIN_SITE }}
  45. - name: Build docs
  46. shell: powershell
  47. working-directory: ./docs
  48. run: |
  49. Add-Content link_branch.json "{`"_gitContribute`":{`"sourceBranch`":`"$env:GITHUB_SHA`",`"apiSpecFolder`":`"docs/override`"}}"
  50. powershell .\build.ps1
  51. if ($lastexitcode -ne 0) {
  52. throw [System.Exception] "docfx build failed with exit code $lastexitcode."
  53. }
  54. - name: Publish tag site to GitHub pages
  55. shell: powershell
  56. working-directory: ./docs
  57. run: |
  58. $ErrorActionPreference = "Continue"
  59. $tagName = (git rev-parse --abbrev-ref=loose $env:GITHUB_REF) -join ""
  60. cd $env:ORIGIN_SITE
  61. if (-Not (Test-Path $env:TAGS_DIR)) {
  62. New-Item -ItemType directory -Path $env:TAGS_DIR
  63. }
  64. $tagPath = "$env:TAGS_DIR/$tagName"
  65. if (Test-Path $tagPath) {
  66. # force remove it
  67. Get-ChildItem -Path $tagPath -Recurse | Remove-Item -Force -Recurse
  68. Remove-Item $tagPath -Force
  69. }
  70. # move generated into place
  71. Move-Item ../_site $tagPath
  72. git add -A 2>&1
  73. git commit -q -a -m "Saved tag $tagName"
  74. git push -q origin gh-pages