Merge pull request #396 from fangzhouli/patch-1 #244
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
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. | |
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
branches: | |
- main | |
- master | |
name: Build and deploy book | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 180 | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
R_KNITR_OPTIONS: "knitr.chunk.tidy=TRUE" | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: Install R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Configure Java for R | |
run: | | |
sudo R CMD javareconf | |
- name: Install OS dependencies | |
run: | | |
sudo apt-get install libcurl4-openssl-dev libharfbuzz-dev libfribidi-dev | |
- name: Install Pandoc | |
uses: r-lib/actions/setup-pandoc@v2 | |
with: | |
pandoc-version: '2.19.2' | |
- name: Install TinyTeX | |
uses: r-lib/actions/setup-tinytex@v2 | |
env: | |
# install full prebuilt version | |
TINYTEX_INSTALLER: TinyTeX | |
- name: Query dependencies | |
run: | | |
install.packages('remotes') | |
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) | |
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") | |
shell: Rscript {0} | |
- name: Install R dependencies for book | |
run: | | |
remotes::install_deps(dependencies = TRUE) | |
shell: Rscript {0} | |
- name: Cache R packages | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} | |
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- | |
- name: Session info | |
run: | | |
options(width = 100) | |
remotes::install_cran("sessioninfo") | |
pkgs <- installed.packages()[, "Package"] | |
sessioninfo::session_info(pkgs, include_base = TRUE) | |
rmarkdown::find_pandoc() | |
shell: Rscript {0} | |
- name: Build HTML, PDF, ebup and mobi | |
run: sh ./_build.sh | |
- name: Checkout gh-pages | |
uses: actions/checkout@v2 | |
with: | |
ref: gh-pages | |
path: out | |
- name: Deploy new book version | |
run: | | |
cd out | |
git rm -rf ./* | |
cp -r ../manuscript/_book/* ./ | |
mkdir -p .github/workflows/ | |
touch .nojekyll | |
git add .nojekyll | |
git add --all ./* | |
git config --local user.email "action@github.com" | |
git config --local user.name "Github Action" | |
git commit -m "Update Book" --allow-empty | |
git push origin gh-pages | |
if: ${{ github.event_name == 'push' }} | |