diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/bookdown.yml b/.github/workflows/bookdown.yml new file mode 100644 index 0000000..854d4bc --- /dev/null +++ b/.github/workflows/bookdown.yml @@ -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/download-artifact@v1.0.0 + 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 }} diff --git a/README.md b/README.md index 18b31be..8063f5a 100644 --- a/README.md +++ b/README.md @@ -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/). diff --git a/renv.lock b/renv.lock index 1d569f4..cd631ed 100644 --- a/renv.lock +++ b/renv.lock @@ -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", diff --git a/renv/activate.R b/renv/activate.R index b852628..304fd90 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -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