Skip to content

Instantly share code, notes, and snippets.

@MGallow
Last active June 21, 2018 00:05
Show Gist options
  • Save MGallow/9759b2659b175233245c102e2b921231 to your computer and use it in GitHub Desktop.
Save MGallow/9759b2659b175233245c102e2b921231 to your computer and use it in GitHub Desktop.
Build, check, AND deploy pkgdown site for R package with Travis
# Thanks to jtilly (https://github.com/jtilly/R-travis-container-example/blob/master/.travis.yml) for the inspiration... has since been slightly modified!
# Requires the generation of a GITHUB_TOKEN to allow Travis to access the repo. See here: https://bookdown.org/yihui/blogdown/travis-github.html
language: r
pandoc_version: 2.2.1
dist: trusty
sudo: false
branches:
only:
- master
# cache local packages
cache: packages
# install required latex packages (if needed)
#before_install:
#- tlmgr install bbm
# install the package and dependencies:
# - update all installed packages
# - install package with dependencies (includes depends, imports, suggests, and linkingto)
install:
- Rscript -e 'update.packages(ask = FALSE)'
- Rscript -e 'devtools::install(pkg = ".", dependencies = TRUE)'
# Build, check package, and create pkgdown site
script:
- R CMD build . --no-build-vignettes --no-manual
- PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)
- R CMD check "${PKG_FILE_NAME}" --no-build-vignettes --no-manual --as-cran
- travis_wait Rscript -e "pkgdown::build_site()"
# deploy site to gh-pages branch
deploy:
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN
on:
branch: master
local_dir: docs
keep-history: true
allow-empty-commit: false
# send email if any changes
notifications:
email:
on_success: change
on_failure: change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment