-
Notifications
You must be signed in to change notification settings - Fork 154
91 lines (80 loc) · 2.96 KB
/
docs_stable.yml
File metadata and controls
91 lines (80 loc) · 2.96 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Build Docs for releases
on:
release:
types: [published]
# No permissions by default
permissions: {}
jobs:
Build-Docs:
runs-on: ${{ github.repository_owner == 'open-edge-platform' && 'overflow' || 'ubuntu-latest' }}
permissions:
contents: write
steps:
- name: Harden the runner (audit all outbound calls)
uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
persist-credentials: false
- name: Install uv and set the python version
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
enable-cache: false
python-version: "3.10"
version: "0.8.15"
- name: Installing dependencies
run: |
sudo apt-get install pandoc graphviz
uv lock --check
uv sync --frozen --extra docs
- name: Build-Docs
run: |
cd docs
uv run make clean
uv run make html
- name: Create gh-pages branch
env:
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
existed_in_remote=$(git ls-remote --heads origin gh-pages)
if [[ -z ${existed_in_remote} ]]; then
echo "Creating gh-pages branch"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout --orphan gh-pages
git reset --hard
touch .nojekyll
git add .nojekyll
git commit -m "Initializing gh-pages branch"
git push origin gh-pages
git checkout "$TAG_NAME"
echo "Created gh-pages branch"
else
echo "Branch gh-pages already exists"
fi
- name: Commit docs to gh-pages branch
env:
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
git fetch
git checkout gh-pages
mkdir -p /tmp/docs_build
cp -r docs/build/html/* /tmp/docs_build/
rm -rf $TAG_NAME/*
echo '<html><head><meta http-equiv="refresh" content="0; url=stable/" /></head></html>' > index.html
mkdir -p $TAG_NAME
cp -r /tmp/docs_build/* ./$TAG_NAME
ln -sfn $TAG_NAME stable
rm -rf /tmp/docs_build
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add ./index.html ./stable $TAG_NAME
git commit -m "Update documentation" -a || true
- name: Push changes
uses: ad-m/github-push-action@77c5b412c50b723d2a4fbc6d71fb5723bcd439aa # v1.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages