-
Notifications
You must be signed in to change notification settings - Fork 48
65 lines (59 loc) · 1.83 KB
/
publish-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: publish docs
on:
push:
branches-ignore:
- v*
tags-ignore:
- v*
jobs:
publish-docs:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
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: 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: ${{ 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'