-
Notifications
You must be signed in to change notification settings - Fork 10
62 lines (58 loc) · 1.79 KB
/
Copy pathdocs-preview.yaml
File metadata and controls
62 lines (58 loc) · 1.79 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
name: Docs Preview
permissions:
contents: write
pull-requests: write
deployments: write
on:
pull_request:
types: [opened, synchronize, reopened, closed]
jobs:
build-and-deploy:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
environment:
name: docs-preview
url: https://sensein.group/senselab/pr-${{ github.event.pull_request.number }}/
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install FFmpeg
run: bash scripts/install-ffmpeg.sh
- name: Install dependencies
run: uv sync --all-extras --group dev --group docs
- name: Build docs
env:
PDOC_ALLOW_EXEC: '1'
run: |
APP_MODULE_NAME=$(ls -1 src | sort | head -1)
uv run pdoc src/"$APP_MODULE_NAME" -o docs -t docs_style/pdoc-theme --docformat google --favicon https://readthedocs.org/favicon.ico
touch docs/.nojekyll
- name: Deploy preview
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs
branch: docs
target-folder: pr-${{ github.event.pull_request.number }}
clean: false
cleanup:
if: github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: docs
fetch-depth: 0
- name: Remove preview
run: |
PR_NUM=${{ github.event.pull_request.number }}
if [ -d "pr-${PR_NUM}" ]; then
git rm -rf "pr-${PR_NUM}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Remove docs preview for PR #${PR_NUM}"
git push origin docs
fi