-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (64 loc) · 1.9 KB
/
on-pull-request.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
on: pull_request
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]
build-book:
runs-on: ubuntu-latest
needs: pre-commit
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Get changed notebooks
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
**.ipynb
- name: Checkout book repo
uses: actions/checkout@v4
with:
repository: ecmwf-projects/c3s_eqc_book_main
path: book
- name: Install jupyter-book
run: |
python -m pip install jupyter-book
- name: Build pages
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |-
mkdir book_preview || exit
cd book/c3s_eqc_quality_assessments || exit
for fullfile in ${ALL_CHANGED_FILES}; do
filename=$(basename -- "$fullfile")
prefix="${filename%.*}"
cp ../../"$fullfile" "$filename" || exit
python ../../scripts/disembed-figures.py "$filename" || exit
jupyter-book build "$filename" || exit
mv _build/_page/"$prefix"/html ../../book_preview/"$prefix" || exit
rm -fr _build
done
- uses: actions/upload-artifact@v4
id: upload-artifact
with:
name: book-preview
path: book_preview/*
- name: Comment PR with book preview url
uses: thollander/actions-comment-pull-request@v2
with:
message: |
**Book preview:** ${{ steps.upload-artifact.outputs.artifact-url }}
comment_tag: artifact-url