-
Notifications
You must be signed in to change notification settings - Fork 235
73 lines (66 loc) · 1.98 KB
/
book.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
name: renderbook
on:
push:
branches:
- master
- develop
tags:
- '*'
pull_request:
merge_group:
jobs:
bookdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
container:
image: pecan/depends:R4.1
steps:
# checkout source code
- uses: actions/checkout@v3
# install rmarkdown
- name: Install rmarkdown
run: |
Rscript -e 'install.packages(c("rmarkdown","bookdown"))'
# copy files
- name: copy extfiles
run: |
mkdir -p book_source/extfiles
cp -f documentation/tutorials/01_Demo_Basic_Run/extfiles/* book_source/extfiles
# compile PEcAn code
- name: build needed modules
run: |
R CMD INSTALL base/logger
R CMD INSTALL base/remote
R CMD INSTALL base/utils
# render book
- name: Render Book
run: |
cd book_source
Rscript -e 'options(bookdown.render.file_scope=FALSE); bookdown::render_book("index.Rmd", "bookdown::gitbook")'
# save artifact
- uses: actions/upload-artifact@v3
with:
name: pecan-documentation
path: book_source/_book/
# download documentation repo
- name: Checkout documentation repo
if: github.event_name == 'push'
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/pecan-documentation
path: pecan-documentation
token: ${{ secrets.GH_PAT }}
# upload new documentation
- name: publish to github
if: github.event_name == 'push'
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Documentation Robot"
export VERSION=$(echo $GITHUB_REF | sed 's,.*/,,' )
cd pecan-documentation
mkdir -p $VERSION
rsync -a --delete ../book_source/_book/ ${VERSION}/
git add --all *
git commit -m "Build book from pecan revision ${GITHUB_SHA}" || true
git push -q origin master