-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (60 loc) · 1.97 KB
/
auto-build.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
name: deploy-book
on:
pull_request:
types:
- review_requested
- synchronize # Checks any commits made to the PR
# This job installs dependencies, builds the book.
jobs:
deploy-book:
runs-on: ubuntu-latest
steps:
- id: repo
name: Repo Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- id: python
name: Python Setup
uses: actions/setup-python@v2
with:
python-version: 3.9
cache: "pip"
- run: pip install -r requirements.txt
# Finds folders that have the _toc.yml file.
- name: List Jupyter Book Folders
id: pl
uses: Rishabh510/Path-lister-action@master
with:
path: "."
type: "_toc.yml"
- name: Build Jupyter Book
run: |
for i in ${{ steps.pl.outputs.paths }}; do
folderName=${i%"_toc.yml"}
# Replace _ with - for built folder name.
newFolderName=${folderName//"_"/"-"}
echo "Building book for $folderName"
# Build the book
jb clean --all ${folderName}
jb build ${folderName}
# Move the files to the docs folder
echo "Moving files to docs/${newFolderName}"
rm -rf docs/${newFolderName}
cp -rf ${folderName}/_build/html/ docs/${newFolderName}
done
- name: Setup Git Config
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Commit Files
run: |
if [[ -n $(git status -s) ]]; then
# Stage the file, commit and push
git add .
git commit -m "auto build from GitHub Actions"
git push origin ${{ github.event.pull_request.head.ref }}
else
echo "No changes since last run"
fi