-
Notifications
You must be signed in to change notification settings - Fork 399
80 lines (68 loc) · 2.59 KB
/
generate-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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Generate PySceneDetect documentation and updates the gh-pages branch.
name: Generate Documentation
on:
push:
branches:
- main # docs/head
- 'releases/**' # docs/**
paths:
- 'docs/**'
workflow_dispatch:
jobs:
update_docs:
runs-on: ubuntu-latest
env:
# TODO: Figure out a better way to handle figuring out what version /latest should be,
# e.g. add a latest version file in main.
scenedetect_docs_latest: '0.6.4'
scenedetect_docs_dest: ''
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Set Destination (Releases)
if: ${{ contains(github.ref_name, 'releases') }}
run: |
echo "scenedetect_docs_dest=$(echo ${{ github.ref_name }} | cut -b 10-)" >> "$GITHUB_ENV"
- name: Set Destination (Head)
if: ${{ contains(github.ref_name, 'main') }}
run: |
echo "scenedetect_docs_dest=head" >> "$GITHUB_ENV"
- name: Check Destination
if: ${{ env.scenedetect_docs_dest == '' }}
run: |
echo "Failing build: destination must be set!"
- name: Setup Environment
run: |
python -m pip install --upgrade pip build wheel virtualenv
pip install -r docs/requirements.txt
pip install -r dist/requirements_windows.txt
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Generate Docs
run: |
sphinx-build -b html docs build
- name: Update gh-pages Branch
run: |
git fetch origin gh-pages
git checkout gh-pages
git rm "docs/${{ env.scenedetect_docs_dest }}" -r -f --ignore-unmatch
git add build/
git mv build "docs/${{ env.scenedetect_docs_dest }}"
- name: Update Latest
if: ${{ env.scenedetect_docs_dest == env.scenedetect_docs_latest }}
run: |
git rm "docs/latest" -r -f --ignore-unmatch
mkdir -p latest
cp -r -f "docs/${{ env.scenedetect_docs_dest }}" docs/latest
git add docs/latest
echo "scenedetect_docs_dest='${{ env.scenedetect_docs_dest }} (latest)'" >> "$GITHUB_ENV"
- name: Commit and Push
run: |
git commit -a -m "[docs] @${{ github.triggering_actor }}: Generate Documentation" \
-m "Source: ${{ github.ref_name }} (${{ github.sha }})" \
-m "Destination: ${{ env.scenedetect_docs_dest }}"
git push