-
Notifications
You must be signed in to change notification settings - Fork 4
145 lines (118 loc) · 4.52 KB
/
workflow.yaml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: renderbook
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
repository_dispatch:
types: [quarto]
env:
BRANCH: ${{ github.event.client_payload.branch }}
REPO: ${{ github.event.client_payload.repo }}
GH_USER: 'RRC_GHA' # must be set
jobs:
quarto:
if: github.event.action == 'quarto' || github.event_name == 'push'
runs-on: ubuntu-latest
# commit book build to RRC repo
permissions:
contents: write
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check name of branch from nceas-training
run: |
echo $BRANCH
- uses: actions/checkout@v3
with:
submodules: true
- name: Checkout repo from branch
uses: actions/checkout@v3
with:
repository: NCEAS/${{ env.REPO }}
ref: "${{ env.BRANCH }}"
path: ${{ env.REPO }}
- uses: Homebrew/actions/setup-homebrew@master
- uses: actions/setup-python@v4
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
- name: System libraries
run: |
sudo apt update
sudo apt-get install -y libjq-dev libudunits2-dev libpoppler-cpp-dev libgdal-dev gdal-bin libproj-dev proj-data proj-bin libgeos-dev librdf0-dev libharfbuzz-dev libspatialindex-dev libfribidi-dev
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Restore R package cache
uses: actions/cache@v3
with:
path: |
${{ env.R_LIBS_USER }}/*
key: ${{ runner.os }}-build-R-${{ hashFiles('**/DESCRIPTION') }}
- name: Install R dependencies
run: |
options(repos = c(REPO_NAME = "https://packagemanager.posit.co/cran/__linux__/jammy/latest"))
install.packages(c("remotes"))
remotes::install_deps()
shell: Rscript {0}
- name: Install dependencies based on branch
run: |
if [[ "${{ env.REPO }}" == "nceas-training" ]]; then
echo "Installing R dependencies"
R -e 'remotes::install_deps(pkgdir="nceas-training/materials")'
elif [[ "${{ env.REPO }}" == "scalable-computing-course" ]]; then
echo "Installing python dependencies"
python3 -m pip install --use-deprecated=legacy-resolver -r scalable-computing-course/requirements.txt
fi
- name: Install pandoc
run: |
brew install pandoc
- name: Install hugo
run: |
Rscript -e 'blogdown::install_hugo(version = "0.59.0")'
- name: Build blogdown site
run: |
Rscript -e 'blogdown::build_site()'
touch public/.nojekyll
cp CNAME public/CNAME
- name: Install Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true # installs tinytex
#- name: Build training materials scalable
# run: sh _build_quarto.sh
- name: Render Quarto training materials
run: |
if [[ "${{ env.REPO }}" == "nceas-training" ]]; then
echo "Rendering nceas-training"
quarto render "nceas-training/materials"
elif [[ "${{ env.REPO }}" == "scalable-computing-course" ]]; then
echo "Rendering scalable-computing-course"
quarto render "scalable-computing-course"
fi
- name: Move training materials to public/$BRANCH
run: |
mkdir -p public/$BRANCH # make dir if none exists
echo $(ls public)
if [[ "${{ env.REPO }}" == "nceas-training" ]]; then
echo $(ls ${{ env.REPO }}/materials)
cp -R '${{ env.REPO }}/materials/_book'/* public/$BRANCH/
elif [[ "${{ env.REPO }}" == "scalable-computing-course" ]]; then
echo $(ls ${{ env.REPO }})
cp -R '${{ env.REPO }}/_book'/* public/$BRANCH/
fi
- name: Commit build
run: |
git config --global user.name $GH_USER
git config --global user.email "[email protected]"
git add public/$BRANCH
git commit -m "Create automated build"
git push
- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages # branch the action should deploy to
folder: public/ # folder the action should deploy