-
Notifications
You must be signed in to change notification settings - Fork 19
79 lines (71 loc) · 2.23 KB
/
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
name: Publish docs via GitHub Pages
on:
push:
branches:
# - main
paths:
- 'mkdocs.yml'
- '.github/workflows/docs.yml'
- 'docs/**'
- 'benchmarks/**/*.md'
- 'post-processing/**/*.md'
pull_request:
branches:
- main
paths:
- 'mkdocs.yml'
- '.github/workflows/docs.yml'
- 'docs/**'
- 'benchmarks/**/*.md'
- 'post-processing/**/*.md'
concurrency:
# Same group concurrency as the `docs_cleanup.yml` workflow, because they both
# git-push to the same branch, so we want to avoid clashes.
group: docs-pushing
jobs:
build:
timeout-minutes: 10
name: Deploy docs
runs-on: ubuntu-latest
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: always.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout main
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10.6'
cache: 'pip'
- name: Install mkdocs
run: pip install mkdocs-material
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: Build docs
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
export MKDOCS_SITE_DIR="site/preview/PR${{ github.event.number }}"
else
export MKDOCS_SITE_DIR="site"
fi
mkdocs build
- name: Deploy docs
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || ! github.event.pull_request.head.repo.fork }}
run: |
cd gh-pages
cp -fr ../site/* .
git config user.name ${{github.actor}}
git config user.email "${{github.actor_id}}+${{github.actor}}@users.noreply.github.com"
git add .
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
COMMIT_MESSAGE="Update docs preview from ${{ github.sha }} for PR #${{ github.event.number }}"
else
COMMIT_MESSAGE="Update docs from ${{ github.sha }}"
fi
git commit -m "${COMMIT_MESSAGE}"
git push origin gh-pages