-
Notifications
You must be signed in to change notification settings - Fork 10
97 lines (83 loc) · 2.5 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Docs
on: [push, pull_request]
jobs:
build_docs:
# This build is to make PR comments for the sphinx warning and check if
# web links are not broken
name: Check links and make PR comments
runs-on: ubuntu-latest
env:
DOCS_PATH: ./doc/_build/html/
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.11'
- name: Install build docs
shell: bash -l {0}
run: |
pip install .'[doc]'
# Add sphinx warnings as PR comments
- uses: sphinx-doc/sphinx-problem-matcher@master
- name: Build docs
shell: bash -l {0}
run: |
cd doc
make SPHINXOPTS="-W --keep-going" html
- uses: actions/upload-artifact@v3
with:
path: ${{ env.DOCS_PATH }}
name: docs_html
- name: Check links
shell: bash -l {0}
run: |
cd doc
make linkcheck
push_docs:
# This build is to push changes to gh-pages branch (https://hyperspy.org/exspy)
needs: build_docs
name: Push to gh-pages
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' && github.repository == 'hyperspy/exspy' }}
permissions:
# needs write permission to push the docs to gh-pages
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: gh-pages
- uses: actions/download-artifact@v3
with:
name: docs_html
path: .
- name: list files
run: |
ls
- name: Git status
run: |
git status
git status -s
if [[ $(git status -s) ]]; then
HAS_CHANGES='true'
else
HAS_CHANGES='false'
fi
echo "HAS_CHANGES=${HAS_CHANGES}" >> $GITHUB_ENV
- name: Commit files
# Skip when there is nothing to commit
if: ${{ env.HAS_CHANGES == 'true' }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "Update docs build" -a
- name: Push changes
if: ${{ env.HAS_CHANGES == 'true' }}
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages