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.8 KiB

4 years ago
  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: Locate MSBuild
  26. uses: microsoft/[email protected]
  27. - name: Setup .NET Core
  28. uses: actions/setup-dotnet@v1
  29. with:
  30. # As usual, obtained from: https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/5.0/releases.json
  31. dotnet-version: "6.0.100" # since we now use this
  32. - name: Log in to package source
  33. shell: pwsh
  34. run: |
  35. dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} `
  36. --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Atlas-Rhythm/index.json"
  37. - name: Clear Nuget Cache
  38. run: dotnet nuget locals all --clear
  39. - name: Nuget Restore
  40. run: msbuild -t:Restore -m
  41. - name: Install DocFX
  42. uses: crazy-max/ghaction-chocolatey@v1
  43. with:
  44. args: install docfx -y
  45. - name: Checkout current pages
  46. uses: actions/checkout@v2
  47. with:
  48. ref: gh-pages
  49. token: ${{ secrets.pagesCommitToken }}
  50. path: docs/${{ env.ORIGIN_SITE }}
  51. - name: Build docs
  52. shell: powershell
  53. working-directory: ./docs
  54. run: |
  55. Add-Content link_branch.json "{`"_gitContribute`":{`"sourceBranch`":`"$env:GITHUB_SHA`",`"apiSpecFolder`":`"docs/override`"}}"
  56. powershell .\build.ps1
  57. if ($lastexitcode -ne 0){
  58. throw [System.Exception] "docfx build failed with exit code $lastexitcode."
  59. }
  60. - name: Publish master site to GitHub pages
  61. shell: powershell
  62. working-directory: ./docs
  63. run: |
  64. Move-Item "$env:ORIGIN_SITE/.git" _site
  65. Move-Item "$env:ORIGIN_SITE/$env:TAGS_DIR" _site
  66. Move-Item "$env:ORIGIN_SITE/$env:BRANCH_DIR" _site
  67. cd _site
  68. $ErrorActionPreference = "SilentlyContinue"
  69. git add -A 2>&1
  70. $srcMessage = (git show -s --format=%B $env:GITHUB_SHA) -join "`n"
  71. git commit -q -a -m "Generated Docs -- $srcMessage"
  72. git push -q origin gh-pages
  73. if: github.ref == 'refs/heads/master'
  74. - name: Publish branch site to GitHub pages
  75. shell: powershell
  76. working-directory: ./docs
  77. run: |
  78. $ErrorActionPreference = "Continue"
  79. $branchName = (git rev-parse --abbrev-ref=loose $env:GITHUB_REF) -join ""
  80. $srcMessage = (git show -s --format=%B $env:GITHUB_SHA) -join "`n"
  81. cd $env:ORIGIN_SITE
  82. if (-Not (Test-Path $env:BRANCH_DIR)) {
  83. New-Item -ItemType directory -Path $env:BRANCH_DIR
  84. }
  85. $branchPath = "$env:BRANCH_DIR/$branchName"
  86. if (Test-Path $branchPath) {
  87. # force remove it
  88. Get-ChildItem -Path $branchPath -Recurse | Remove-Item -Force -Recurse
  89. Remove-Item $branchPath -Force
  90. }
  91. # move generated into place
  92. Move-Item ../_site $branchPath
  93. git add -A 2>&1
  94. git commit -q -a -m "Generated Docs ($branchName) -- $srcMessage"
  95. git push -q origin gh-pages
  96. if: github.ref != 'refs/heads/master'