Still... #111
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: [main, master, v2] | |
pull_request: | |
branches: [main, master, v2] | |
workflow_dispatch: | |
name: bookdown | |
jobs: | |
bookdown: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_PAT }} | |
EMAIL: ${{ secrets.EMAIL }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
# Install tinytex and LaTeX packages | |
- name: Install tinytex | |
run: | | |
R -e 'install.packages("tinytex"); tinytex::install_tinytex()' | |
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"))' | |
shell: bash | |
# Install fonts | |
- name: Install fonts | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y fonts-inconsolata fonts-nanum | |
sudo fc-cache -fv | |
shell: bash | |
# Install R packages with retry logic | |
- name: Install R packages with retry logic | |
run: | | |
R -e 'for (i in 1:5) { tryCatch(remotes::install_github("tidymodels/infer"), error = function(e) Sys.sleep(30)) }' | |
R -e 'for (i in 1:5) { tryCatch(remotes::install_github("haozhu233/kableExtra"), error = function(e) Sys.sleep(30)) }' | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_PAT }} | |
- uses: r-lib/actions/setup-renv@v2 | |
- name: Cache bookdown results | |
uses: actions/cache@v3 | |
with: | |
path: _bookdown_files | |
key: bookdown-${{ hashFiles('**/*Rmd') }} | |
restore-keys: bookdown- | |
- name: Build PDF book | |
run: | | |
R -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book")' | |
- name: Build HTML book | |
run: | | |
R -e 'bookdown::render_book("index.Rmd", "bookdown::bs4_book")' | |
# Deploy HTML to GitHub Pages if on main or master branch | |
- name: Deploy to GitHub pages 🚀 | |
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages | |
folder: docs | |
# Deploy to v2-publish if on v2 branch | |
- name: Deploy to v2-publish branch 🚀 | |
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/v2' | |
uses: JamesIves/[email protected] | |
with: | |
branch: v2-publish | |
folder: docs | |
# Optional: Save PDF to GitHub Releases | |
- name: Upload PDF to GitHub Release | |
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: "*.pdf" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |