Deploy your package to a github drat repo from Travis-CI.
This R package is heavily inspired by Colin Gillespie and Dirk Eddelbuettel's blog post http://eddelbuettel.github.io/drat/CombiningDratAndTravis.html.
From Dirk's blog:
To allow Travis CI to push to your GitHub repository, we need to generate a GitHub API token. After re-entering your password, just select
repo
, or if your repository is public, selectpublic_repo
. GitHub will create the token and give you a chance to copy it down.
I recommend making a public_repo
token only as the drat repo will be publicly available on the gh-pages branch.
drat
RepoCreate a new github repository called drat
with a gh-pages branch. drat
will take care of the rest.
Once your Github drat
repo is available, create and init the gh-pages
branch programatically with...
# Create local github drat repo
drat::initRepo("drat", ".")
# Init drat repo
repo <- git2r::repository("drat")
# Add github remote to the global defined github user
git2r::remote_add(repo, "origin", paste0("https://github.com/", git2r::config()$global$github.user, "/drat.git"))
# Push the init'ed repo
git2r::push(repo, "origin", "refs/heads/gh-pages", credentials = git2r::cred_token())
# Delete local repo (not needed anymore)
unlink("drat", recursive = TRUE)
To verify that it was successful, visit your newly created github webpage. Mine is https://schloerke.github.io/drat/README.md
Visit your profile on Travis. Make sure your R package repository is active and ready to be checked on Travis.
Create a secure personal access token (PAT) that can be used in Travis safely.
# Add the token to env.global automatically
travisDrat::secure_token()
# Display only
travisDrat::secure_token(add = FALSE)
The .travis.yml
file should contain the fields:
env:
global:
secure: "REALLYLONGENCRYPTEDKEYTHATISNOTHUMANREADABLE"
.travis.yml
Add the following lines to your travis file:
r_github_packages:
- schloerke/travisDrat
after_success:
- Rscript -e "travisDrat::deploy_drat()"
Push commits to Github. Travis will activate on the package web hook. After a successful check of your R package, travisDrat
will deploy to the drat repo provided.
# Add personal drat repo
drat::addRepo("schloerke")
# Add any github user drat repo
drat::addRepo("GITHUB_USER")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.