Skip to content

Commit ea76964

Browse files
authored
Merge pull request #525 from moderndive/test-ga-master-build
Test ga master build
2 parents 0998e78 + 502f2fe commit ea76964

File tree

2 files changed

+133
-17
lines changed

2 files changed

+133
-17
lines changed

.github/workflows/deploy_bookdown.yml

+132-16
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,166 @@
1-
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2-
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3-
4-
# Set up renv following instructions at https://www.emilhvitfeldt.com/post/bookdown-netlify-github-actions/
51
on:
62
push:
7-
branches: [main, master]
3+
branches: [main, master, v2]
84
pull_request:
9-
branches: [main, master]
5+
branches: [main, master, v2]
106
workflow_dispatch:
117

128
name: bookdown
139

1410
jobs:
1511
bookdown:
1612
runs-on: ubuntu-latest
17-
# Only restrict concurrency for non-PR jobs
1813
concurrency:
1914
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
2015
env:
21-
GITHUB_PAT: ${{ secrets.GH_PAT }}
16+
GITHUB_PAT: ${{ secrets.GITHUB_PAT }}
2217
EMAIL: ${{ secrets.EMAIL }}
2318
steps:
24-
- uses: actions/checkout@v3
19+
# Checkout repository
20+
- uses: actions/checkout@v4
2521

22+
# Setup Pandoc
2623
- uses: r-lib/actions/setup-pandoc@v2
2724

25+
# Setup R environment with RSPM enabled
2826
- uses: r-lib/actions/setup-r@v2
2927
with:
3028
use-public-rspm: true
3129

30+
# Restore cached package and TinyTeX state files
31+
- name: Cache package state
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
installed_packages.rds
36+
tinytex_packages.rds
37+
key: package-state-${{ runner.os }}-${{ hashFiles('**/renv.lock') }}
38+
restore-keys: package-state-${{ runner.os }}-
39+
40+
# Check and install R packages if needed
41+
- name: Check and Install R Packages
42+
run: |
43+
R -e '
44+
if (file.exists("installed_packages.rds")) {
45+
saved_pkgs <- readRDS("installed_packages.rds");
46+
current_pkgs <- installed.packages();
47+
if (!identical(saved_pkgs[,1], current_pkgs[,1])) {
48+
missing_pkgs <- setdiff(rownames(saved_pkgs), rownames(current_pkgs));
49+
if (length(missing_pkgs) > 0) install.packages(missing_pkgs);
50+
} else {
51+
cat("No package changes detected.\n");
52+
}
53+
} else {
54+
install.packages(c("tidyverse", "bookdown"));
55+
}'
56+
env:
57+
GITHUB_PAT: ${{ secrets.GITHUB_PAT }}
58+
59+
# Install and cache TinyTeX only if needed
60+
- name: Install TinyTeX if Needed
61+
run: |
62+
if ! command -v tlmgr &> /dev/null; then
63+
R -e 'install.packages("tinytex"); tinytex::install_tinytex()';
64+
R -e 'tinytex::tlmgr_install(c("xetex", "fontspec", "xunicode", "geometry", "fancyhdr", "titlesec", "titling", "tocloft", "sectsty", "environ", "trimspaces", "wrapfig", "multirow", "colortbl", "tabularx", "varwidth", "footnote", "threeparttable", "enumitem", "footmisc", "fncychap", "hyphenat", "biblatex", "biber"))';
65+
else
66+
echo "TinyTeX is already installed";
67+
fi
68+
shell: bash
69+
70+
# Cache TinyTeX installation
71+
- name: Cache TinyTeX installation
72+
uses: actions/cache@v4
73+
with:
74+
path: ~/.TinyTeX
75+
key: tinytex-${{ runner.os }}-${{ hashFiles('**/*.tex') }}
76+
restore-keys: tinytex-
77+
78+
# Install fonts only if needed
79+
- name: Check and Install Fonts
80+
run: |
81+
if ! fc-list | grep -q "Inconsolata"; then
82+
sudo apt-get update;
83+
sudo apt-get install -y fonts-inconsolata fonts-nanum;
84+
sudo fc-cache -fv;
85+
else
86+
echo "Fonts are already installed";
87+
fi
88+
shell: bash
89+
90+
# Setup renv if needed
3291
- uses: r-lib/actions/setup-renv@v2
3392

93+
# Ensure _bookdown_files directory exists
94+
- name: Ensure _bookdown_files directory exists
95+
run: mkdir -p _bookdown_files
96+
97+
# Cache bookdown results
3498
- name: Cache bookdown results
35-
uses: actions/cache@v3
99+
uses: actions/cache@v4
36100
with:
37101
path: _bookdown_files
38102
key: bookdown-${{ hashFiles('**/*Rmd') }}
39103
restore-keys: bookdown-
40104

41-
- name: Build site
42-
run: bookdown::render_book("index.Rmd", quiet = TRUE)
43-
shell: Rscript {0}
105+
# Check if bookdown::pdf_book is enabled (not commented out) in _output.yml
106+
- name: Check for uncommented pdf_book in _output.yml
107+
id: check_pdf
108+
run: |
109+
if grep -qE '^[^#]*bookdown::pdf_book' _output.yml; then
110+
echo "PDF book is enabled.";
111+
echo "build_pdf=true" >> $GITHUB_ENV;
112+
else
113+
echo "PDF book is not enabled.";
114+
echo "build_pdf=false" >> $GITHUB_ENV;
115+
fi
116+
117+
# Build PDF book if enabled
118+
- name: Build PDF book
119+
if: env.build_pdf == 'true'
120+
run: |
121+
R -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book")'
122+
123+
# Build HTML books
124+
- name: Build HTML gitbook book
125+
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') || github.event_name == 'pull_request'
126+
run: |
127+
R -e 'bookdown::render_book("index.Rmd", "bookdown::gitbook")'
128+
129+
- name: Build HTML bs4_book book
130+
if: github.ref == 'refs/heads/v2' || github.event_name == 'pull_request'
131+
run: |
132+
R -e 'bookdown::render_book("index.Rmd", "bookdown::bs4_book")'
133+
134+
# Save R package state and TinyTeX installation to RDS files
135+
- name: Save R Package and TinyTeX State
136+
run: |
137+
R -e 'saveRDS(installed.packages(), file = "installed_packages.rds")';
138+
R -e 'tinytex_packages <- tinytex::tl_pkgs(); saveRDS(tinytex_packages, file = "tinytex_packages.rds")'
139+
140+
# Deploy HTML to GitHub Pages if on main or master branch
141+
- name: Deploy to GitHub pages from main/master 🚀
142+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
143+
uses: JamesIves/[email protected]
144+
with:
145+
branch: gh-pages
146+
folder: docs
147+
clean: false
148+
149+
# Deploy to v2-publish if on v2 branch
150+
- name: Deploy to v2-publish branch from v2 🚀
151+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/v2'
152+
uses: JamesIves/[email protected]
153+
with:
154+
branch: v2-publish
155+
folder: docs
156+
clean: false
44157

45-
- name: Deploy to GitHub pages 🚀
46-
if: github.event_name != 'pull_request'
47-
uses: JamesIves/[email protected]
158+
# Deploy to /v2 subdirectory of gh-pages from v2 branch
159+
- name: Deploy to v2 subdirectory of gh-pages 🚀
160+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/v2'
161+
uses: JamesIves/[email protected]
48162
with:
49163
branch: gh-pages
50164
folder: docs
165+
target-folder: v2 # Specify the target subdirectory
166+
clean: false

00-preface.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Chester Ismay | Albert Y. Kim
251251
:-------------------------:|:-------------------------:
252252
`r include_image(path = "images/ismay.png", html_opts = "height=220px", latex_opts = "width=46%")` | `r include_image(path = "images/kim.png", html_opts = "height=220px", latex_opts = "width=46%")`
253253

254-
**Chester Ismay** is Director of Data Science Education at Flatiron School, working remotely from Portland, OR, USA. In this role, he leads the data science curriculum and instructional coordination teams at Flatiron School. He completed his PhD in statistics from Arizona State University in 2013. He has previously worked in a variety of roles including as an actuary at Scottsdale Insurance Company (now Nationwide E&S/Specialty), as a freelance data science consultant, and at Ripon College, Reed College, and Pacific University. Prior to joining Flatiron School, he was a Data Science Evangelist at DataRobot, where he led data science, machine learning, and data engineering in-person and virtual workshops for DataRobot University. In addition to his work for *ModernDive*, he also contributed as initial developer of the [`infer`](https://cran.r-project.org/package=infer) R package and is author and maintainer of the [`thesisdown`](https://github.com/ismayc/thesisdown) R package.
254+
**Chester Ismay** is Vice President of Data and Automation at MATE Seminars and is a freelance data science consultant and instructor. He also teaches in the Center for Executive and Professional Education at Portland State University. He completed his PhD in statistics from Arizona State University in 2013. He has previously worked in a variety of roles including as an actuary at Scottsdale Insurance Company (now Nationwide E&S/Specialty) and at Ripon College, Reed College, and Pacific University. He has experience working in online education and was previously a Data Science Evangelist at DataRobot, where he led data science, machine learning, and data engineering in-person and virtual workshops for DataRobot University. In addition to his work for *ModernDive*, he also contributed as initial developer of the [`infer`](https://cran.r-project.org/package=infer) R package and is author and maintainer of the [`thesisdown`](https://github.com/ismayc/thesisdown) R package.
255255

256256
257257
* Webpage: <https://chester.rbind.io/>

0 commit comments

Comments
 (0)