-
Notifications
You must be signed in to change notification settings - Fork 19
92 lines (76 loc) · 2.04 KB
/
top-level.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
81
82
83
84
85
86
87
88
89
90
91
92
on:
push:
branches:
- main
pull_request:
jobs:
build-doc:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/checkout@v4
with:
lfs: 'true'
- name: Install pip packages
working-directory: docs
run: |
pip install pip --upgrade
pip install -r requirements.txt --upgrade
- name: Build doc
working-directory: docs
run: |
make html
- name: Store the generated doc
uses: actions/upload-artifact@v4
with:
name: html
path: docs/_build/html
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: [build-doc]
permissions:
contents: write
steps:
- run: |
git config --global user.name "${{ github.event.head_commit.committer.name }}"
git config --global user.email "${{ github.event.head_commit.committer.email }}"
- uses: actions/checkout@v4
- name: Create gh-pages branch
run: >
git ls-remote --exit-code --heads origin refs/heads/gh-pages ||
(
git reset --hard ;
git clean -fdx ;
git checkout --orphan gh-pages ;
git reset --hard;
git commit -m "empty" --allow-empty ;
git push origin gh-pages:gh-pages
)
- uses: actions/checkout@v4
with:
ref: 'gh-pages'
lfs: 'false'
- name: Empty gh-pages
run: |
git rm -r . --quiet || true
- uses: actions/download-artifact@v4
with:
name: html
- name: Patch doc build
run: |
rm -r _sources
touch .nojekyll
- name: Commit gh-pages
run: |
author=$(git log -1 --pretty=format:'%an')
email=$(git log -1 --pretty=format:'%ae')
commit=$(git rev-parse --short HEAD)
git add . >> /dev/null
git commit -m "deploy: ${GITHUB_SHA}" --allow-empty
- name: Push to gh-pages
run: >-
git push origin gh-pages:gh-pages