-
Notifications
You must be signed in to change notification settings - Fork 20
Travis
Travis now has built-in support for this: https://docs.travis-ci.com/user/deployment/pages/
- Install Ruby.
- Install Travis:
gem install travis
- Go to GitHub Settings, Personal access tokens and generate a token with the following scopes: repo (
repo:status
,repo_deployment
,public_repo
). Make sure you also tickrepo
. - Navigate to the repository. Create the
.travis.yml
configuration file if it does not exist. - Issue the following command:
travis encrypt GH_TOKEN=your_token -add
(note the quotes) - Commit the
.travis.yml
configuration file and push.
The secure:
string for the GitHub token is interpreted by Travis as $ export GH_TOKEN=[secure]
. If Travis does not evaluate the secure string, you should check the repository endpoints of the ~/.travis/config.yml
configuration file. For example, if a public repository was made private, the endpoint should be 1) changed from api.travis-ci.org
to api.travis-ci.com
or 2) simply removed (the travis
command will ask you and add the proper one instead).
There is a solution to build R projects on Travis, but it may not be suitable to you if R is only a part of a bigger project. To run R manually, the following steps are needed.
A simple way is to put r-base
and r-base-dev
into the apt packages section. However, it might not work when you want to install certain packages (or their dependencies), because they are built from source and might require newer version of R. A more complex (but more likely working) solution is the following.
sudo: required
addons:
apt:
packages:
# Required for R
- libxml2-dev
- libcurl4-openssl-dev
- libssl-dev
install:
# Installing R is done here to ensure that newer version is installed (required by packages)
- sudo add-apt-repository -y "deb https://cran.cnr.berkeley.edu/bin/linux/ubuntu trusty/"
- sudo apt-get update
- sudo apt-get install -y --force-yes r-base r-base-dev
# Pandoc (for markdown)
- sudo add-apt-repository -y ppa:marutter/c2d4u
- sudo apt-get update
- sudo apt-get install -y --force-yes pandoc
# Packages (takes a long time due to compilation from source)
- sudo Rscript install.R
Some libraries are added as apt packages, but R and Pandoc (required for R markdown) are installed manually to ensure that new versions are installed. The install.R
script must contain the packages to be installed as follows.
install.packages('rmarkdown', repos='http://cran.us.r-project.org')
install.packages('tidyverse', repos='http://cran.us.r-project.org')
Simply run the R script in the script
part of .travis.yml
. For example, to render a markdown file, use the command
Rscript -e "rmarkdown::render('report.Rmd')"
.