Skip to content

Commit

Permalink
Switch to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Oct 16, 2020
1 parent aebe80e commit e378d87
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
100 changes: 100 additions & 0 deletions .github/workflows/build-book.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
# run every day at 11 PM
- cron: '0 23 * * *'

name: build-book


jobs:
build:
runs-on: macOS-latest
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
isExtPR: ${{ github.event.pull_request.head.repo.fork == true }}
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup R
uses: r-lib/actions/setup-r@master
with:
crayon.enabled: 'FALSE'

- uses: r-lib/actions/setup-pandoc@master

- name: Get R version
id: get-r-version
run: |
echo "::set-output name=version::$(Rscript -e 'cat(as.character(getRversion()))')"
shell: bash

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ steps.get-r-version.outputs.version }}-1-

- name: Cache bookdown results
uses: actions/cache@v2
with:
path: _bookdown_files
key: bookdown-9-${{ hashFiles('**/*Rmd') }}
restore-keys: bookdown-9-

- name: Install pak
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
shell: Rscript {0}

- name: Install macOS system dependencies
if: runner.os == 'macOS'
run: |
brew install libgit2
- name: Install dependencies
run: |
pak::local_install_dev_deps()
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Configure Git user
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
- name: Build site
run: Rscript -e 'bookdown::render_book("index.Rmd", quiet = TRUE)'

- name: Copy
run: cp _redirects _book/

- name: Deploy to Netlify
if: contains(env.isExtPR, 'false')
id: netlify-deploy
uses: nwtgck/[email protected]
with:
publish-dir: './_book'
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message:
'Deploy from GHA: ${{ github.event.pull_request.title || github.event.head_commit.message }} (${{ github.sha }})'
# these all default to 'true'
enable-pull-request-comment: false
enable-commit-comment: false
# enable-commit-status: true
#o verwrites-pull-request-comment: true
timeout-minutes: 1
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Rendered product: <https://happygitwithr.com>

<a alt = "TravisCI Build Status" href="https://travis-ci.org/jennybc/happy-git-with-r"><img src="https://travis-ci.org/jennybc/happy-git-with-r.svg?branch=master" height = 20 /></a>
<!-- badges: start -->
[![R build status](https://github.com/jennybc/happy-git-with-r/workflows/build-book/badge.svg)](https://github.com/jennybc/happy-git-with-r/actions)
[![Netlify Status](https://api.netlify.com/api/v1/badges/4e9fea2e-d99c-484e-be1a-9d8605393f4e/deploy-status)](https://app.netlify.com/sites/happygitwithr/deploys)
<!-- badges: end -->


<a alt = "Netlify Delopyments" href="https://app.netlify.com/sites/happygitwithr/deploys"><img src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg" height = 20 /></a>
<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png" height = 20 /></a>

0 comments on commit e378d87

Please sign in to comment.