Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build docs for every branches #2863

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ name: publish docs

on:
push:
branches:
- main
branches-ignore:
- v*
tags-ignore:
- v*

jobs:
publish-docs:
Expand All @@ -17,18 +19,48 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
fetch-tags: true
- name: Dotnet Setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.400

- run: dotnet restore
- run: dotnet tool restore
- run: docfx docs/docfx.json
- 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%</title>*}</title>"
echo "<meta http-equiv=\"refresh\" content=\"0;${{ github.ref_name }}/\">"
echo "<base href=\"${{ github.ref_name }}/\">"
echo -n "${index#*</title>}"
} > /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'
Loading