From 57b3d3a31f23e5711058fe5c9c85bbe6e58b138f Mon Sep 17 00:00:00 2001 From: moreal Date: Fri, 27 Sep 2024 17:45:28 +0900 Subject: [PATCH 1/2] Fix docfx command usage in CI --- .github/workflows/publish-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 17286c496..e4243ae49 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -24,7 +24,7 @@ jobs: - run: dotnet restore - run: dotnet tool restore - - run: docfx docs/docfx.json + - run: dotnet docfx docs/docfx.json - name: deploy uses: peaceiris/actions-gh-pages@v4 From 1347e5239e73419d676c7ae2131cb7d7b484b18f Mon Sep 17 00:00:00 2001 From: moreal Date: Fri, 27 Sep 2024 16:58:32 +0900 Subject: [PATCH 2/2] Build docs for every branches --- .github/workflows/publish-docs.yml | 38 +++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index e4243ae49..eb4c30669 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -2,8 +2,10 @@ name: publish docs on: push: - branches: - - main + branches-ignore: + - v* + tags-ignore: + - v* jobs: publish-docs: @@ -17,6 +19,7 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + fetch-tags: true - name: Dotnet Setup uses: actions/setup-dotnet@v4 with: @@ -26,9 +29,38 @@ jobs: - run: dotnet tool restore - run: dotnet docfx docs/docfx.json + - name: update index.html + run: | + set -ev + + if [[ "${{ github.ref_name }}" =~ ^v ]]; then + echo "Prevent tags started with 'v'" >&2 + exit + fi + + mkdir -p /tmp/gh-pages-root + latest_version=$(git tag --sort -v:refname | grep -E -i '^[0-9]+\.[0-9]+\.[0-9]+' | head -n 1) + if [[ "$latest_version" = "${{ github.ref_name }}" ]]; then + index=$(cat docs/_site/index.html) + { + echo -n "${index%*}" + echo "" + echo "" + echo -n "${index#*}" + } > /tmp/gh-pages-root/index.html + fi + if: github.ref_type == 'tag' - name: deploy uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/_site/ - destination_dir: docs + destination_dir: ${{ github.ref_name }} + - name: deploy (index.html) + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: /tmp/gh-pages-root + destination_dir: . + keep_files: true + if: github.ref_type == 'tag'