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.

80 lines
3.0 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: "6.0.100" # since we now use this
  31. - name: Log in to package source
  32. shell: pwsh
  33. run: |
  34. dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} `
  35. --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Atlas-Rhythm/index.json"
  36. - name: Clear Nuget Cache
  37. run: dotnet nuget locals all --clear
  38. - name: Nuget Restore
  39. run: msbuild -t:Restore -m
  40. - name: Install DocFX
  41. uses: crazy-max/ghaction-chocolatey@v1
  42. with:
  43. args: install docfx -y
  44. - name: Checkout current pages
  45. uses: actions/checkout@v2
  46. with:
  47. ref: gh-pages
  48. token: ${{ secrets.pagesCommitToken }}
  49. path: docs/${{ env.ORIGIN_SITE }}
  50. - name: Build docs
  51. shell: powershell
  52. working-directory: ./docs
  53. run: |
  54. Add-Content link_branch.json "{`"_gitContribute`":{`"sourceBranch`":`"$env:GITHUB_SHA`",`"apiSpecFolder`":`"docs/override`"}}"
  55. powershell .\build.ps1
  56. if ($lastexitcode -ne 0) {
  57. throw [System.Exception] "docfx build failed with exit code $lastexitcode."
  58. }
  59. - name: Publish tag site to GitHub pages
  60. shell: powershell
  61. working-directory: ./docs
  62. run: |
  63. $ErrorActionPreference = "Continue"
  64. $tagName = (git rev-parse --abbrev-ref=loose $env:GITHUB_REF) -join ""
  65. cd $env:ORIGIN_SITE
  66. if (-Not (Test-Path $env:TAGS_DIR)) {
  67. New-Item -ItemType directory -Path $env:TAGS_DIR
  68. }
  69. $tagPath = "$env:TAGS_DIR/$tagName"
  70. if (Test-Path $tagPath) {
  71. # force remove it
  72. Get-ChildItem -Path $tagPath -Recurse | Remove-Item -Force -Recurse
  73. Remove-Item $tagPath -Force
  74. }
  75. # move generated into place
  76. Move-Item ../_site $tagPath
  77. git add -A 2>&1
  78. git commit -q -a -m "Saved tag $tagName"
  79. git push -q origin gh-pages