generated from Southampton-RSG-Training/workshop-template
-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (80 loc) · 3.41 KB
/
website.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
name: Website
on:
push:
branches:
- "main"
pull_request: null
jobs:
build-website:
runs-on: ubuntu-latest
env:
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout the lesson
uses: actions/checkout@v2
- name: Install sys deps
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev
- name: Setup Git
if: ${{ !env.ACT }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Python modules
run: |
python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
python3 -m pip install -r requirements.txt
- name: Get the submodules using python
run: |
python bin/get_submodules.py
- name: Check for Rmd
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "_episodes_rmd"
- name: Setup Pandoc
if: steps.check_files.outputs.files_exists == 'true'
uses: r-lib/actions/setup-pandoc@v1
- name: Setup R
if: steps.check_files.outputs.files_exists == 'true'
uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
- name: Setup Renv
if: steps.check_files.outputs.files_exists == 'true'
uses: r-lib/actions/setup-renv@v2
# This task:
# 1: Finds the file paths for all RMarkdown scripts
# 2: Runs the RScript command to knit each R script, specifying the md collection as the destination
# - See r-novice_setup.R in each R directory to see the custom modifications we make to the knitting process
# 3: Use a perl regex to reformat SWC commands, the knit process misplaces them
# 4: Use a perl regex to find specific challenge tags
# 5: Add the episodes in the markdown folder
# 6: Commit the changes to be added to the GH pages episode later
- name: Render R markdown
if: steps.check_files.outputs.files_exists == 'true'
run: |
RMD_PATH=$(find ./_episodes_rmd -name '*.Rmd')
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f, knit_root_dir=getwd(), output_dir=dirname(sub("./_episodes_rmd/", "./_episodes/", f)))' ${RMD_PATH[*]}
perl -pi -e "s/([>\s]*)(>\s)(.*?)(\{: \.[a-zA-Z]+\})/\1\2\3\n\1\4\n\1/g" ./collections/_episodes/r-novice-lesson/*.md
perl -0777pi -e "s/(?<!\n){: .challenge}/\n{: .challenge}/g" ./collections/_episodes/r-novice-lesson/*.md
cp ./_episodes_rmd/**/fig/*.png ./fig/
git add ./_episodes/**/*.md ./fig/*.png
git commit ./_episodes/**/*.md ./fig/*.png -m 'Re-build Rmarkdown files' || echo "No changes to commit"
- name: Run python build scripts
run: |
python bin/make_favicons.py
python bin/get_schedules.py
python bin/get_setup.py
- name: Deploy the website to gh-pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: "."
token: ${{ secrets.GITHUB_TOKEN }}