Skip to content

Commit

Permalink
add actions and update renv
Browse files Browse the repository at this point in the history
  • Loading branch information
nhejazi committed Oct 13, 2021
1 parent 5ac3edc commit d55e061
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
102 changes: 102 additions & 0 deletions .github/workflows/bookdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
on:
push:
branches:
- master

name: booklet

jobs:
bookdown:
name: build-bookdown
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv

steps:
- name: Checkout repo
uses: actions/checkout@v2

#- name: Setup upterm session
#uses: lhotari/action-upterm@v1

- name: Setup R
uses: r-lib/actions/setup-r@master
with:
r-version: '4.1.1'

- name: Install pandoc
uses: r-lib/actions/setup-pandoc@v1

- name: Install tinyTeX
uses: r-lib/actions/setup-tinytex@v1

- name: Install system dependencies
run: |
sudo apt install -y curl libcurl4-doc libcurl4-openssl-dev libmagick++-dev libpoppler-cpp-dev texlive-extra-utils ghostscript
- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- name: Restore R packages
shell: Rscript {0}
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::restore()
- name: Cache bookdown results
uses: actions/cache@v2
with:
path: _bookdown_files
key: bookdown-2-${{ hashFiles('**/*Rmd') }}
restore-keys: bookdown-2-

- name: Render book HTML
run: |
Rscript -e 'bookdown::clean_book(TRUE)'
Rscript -e 'bookdown::render_book("index.Rmd", quiet = TRUE)'
- name: Render book PDF
run: |
Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book")'
- uses: actions/upload-artifact@v1
with:
name: _book
path: _book/

# Need to first create an empty gh-pages branch
# see https://pkgdown.r-lib.org/reference/deploy_site_github.html
# and also add secrets for a GH_PAT and EMAIL to the repository
# gh-action from https://github.com/Cecilapp/GitHub-Pages-deploy
checkout-and-deploy:
runs-on: ubuntu-latest
needs: bookdown
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Download Artifact
uses: actions/[email protected]
with:
# Artifact name
name: _book # optional
# Destination path
path: _book # optional

- name: Abbreviate Git SHA
run: echo "GITHUB_SHA_SHORT=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV

- name: Deploy to GitHub Pages
uses: Cecilapp/GitHub-Pages-deploy@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
email: ${{ secrets.EMAIL }} # must be a GitHub-verified email
build_dir: _book/ # "_site/" by default
commit_message: Update book via ${{ env.GITHUB_SHA_SHORT }}
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# The `tlverse` handbook

[![Travis-CI Build Status](https://travis-ci.com/tlverse/tlverse-handbook.svg?branch=master)](https://travis-ci.com/tlverse/tlverse-handbook)
Note: `travis-ci` currently deploys the developmental version of this workshop
handbook into the `gh-pages` branch of this repository, which is hosted by
GitHub Pages at https://tlverse.org/tlverse-handbook.
# The `tlverse` handbook [![Booklet](https://github.com/tlverse/tlverse-handbook/actions/workflows/bookdown.yml/badge.svg)](https://github.com/tlverse/tlverse-handbook/actions/workflows/bookdown.yml)

Welcome to the GitHub repository for drafts of [**Targeted Learning in `R`:
Causal Data Science with the `tlverse` Software
Ecosystem**](http://tlverse.org/tlverse-handbook), by Mark van der Laan, Jeremy
Coyle, Nima Hejazi, Ivana Malenica, Rachael Phillips, and Alan Hubbard. This
draft is work-in-progress and updates are made available frequently. The book is
A Causal Data Science Handbook**](http://tlverse.org/tlverse-handbook), by Mark
van der Laan, Jeremy Coyle, Nima Hejazi, Ivana Malenica, Rachael Phillips, and
Alan Hubbard. This draft is work-in-progress and updates are made available
frequently. The draft has been made publicly available in order to solicit
feedback (and errata) transparently from the interested community. The book is
built using RStudio's
[`bookdown`](https://www.rstudio.com/resources/webinars/introducing-bookdown/)
`R` package; for more information on how to use `bookdown` see
[bookdown.org](https://bookdown.org/).
`R` package; see [bookdown.org](https://bookdown.org/) for more information on
how to use `bookdown`. The online book is automatically built and deployed via
[GitHub Actions](https://github.com/features/actions) and served to
https://tlverse.org/tlverse-handbook by [GitHub
Pages](https://pages.github.com/).
6 changes: 2 additions & 4 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1222,10 +1222,8 @@
},
"renv": {
"Package": "renv",
"Version": "0.13.2",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "079cb1f03ff972b30401ed05623cbe92"
"Version": "0.14.0",
"Source": "Repository"
},
"repr": {
"Package": "repr",
Expand Down
18 changes: 16 additions & 2 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@
local({

# the requested version of renv
version <- "0.13.2"
version <- "0.14.0"

# the project directory
project <- getwd()

# allow environment variable to control activation
activate <- Sys.getenv("RENV_ACTIVATE_PROJECT")
if (!nzchar(activate)) {

# don't auto-activate when R CMD INSTALL is running
if (nzchar(Sys.getenv("R_INSTALL_PKG")))
return(FALSE)

}

# bail if activation was explicitly disabled
if (tolower(activate) %in% c("false", "f", "0"))
return(FALSE)

# avoid recursion
if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA)))
if (nzchar(Sys.getenv("RENV_R_INITIALIZING")))
return(invisible(TRUE))

# signal that we're loading renv during R startup
Expand Down

0 comments on commit d55e061

Please sign in to comment.