generated from jhudsl/OTTR_Template
-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (87 loc) · 3.4 KB
/
render-bookdown.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# This code was originally written by Josh Shapiro and Candace Savonen
# for the Childhood Cancer Data Lab, an initiative of Alexs Lemonade Stand Foundation.
# https://github.com/AlexsLemonade/refinebio-examples/blob/33cdeff66d57f9fe8ee4fcb5156aea4ac2dce07f/.github/workflows/style-and-sp-check.yml#L1
# Adapted for this jhudsl repository by Candace Savonen Apr 2021
name: Render Bookdown and Coursera
# Controls when the action will run. Triggers the workflow on push
# events only for the master branch
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- '**.Rmd'
- docker/Dockerfile
- assets/*
jobs:
# This workflow contains a single job called "build-all"
build-all:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout
uses: actions/checkout@v2
with:
# get the full repo
fetch-depth: 0
# use github PAT
token: ${{ secrets.GH_PAT }}
###### If you will be making changes to the Docker image to make specific to the
###### course, then highlight this chunk and uncomment it. #####################
###### Recommend using short cut -- Command and / works for some editors.#######
###### START OF DOCKER UPDATE CHUNK
# # Login to Dockerhub
# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
#
# # Set up Docker build
# - name: Set up Docker Build
# uses: docker/setup-buildx-action@v1
#
# - name: Get Token
# run: echo ${{ secrets.GH_PAT }} > docker/git_token.txt
#
# # Build docker image
# - name: Build Docker image
# uses: docker/build-push-action@v2
# with:
# push: false
# load: true
# context: docker
# file: docker/Dockerfile
# tags: jhudsl/course_template
#
# # Push the Docker image
# - name: Push Docker image
# run: docker push jhudsl/course_template
###### END OF DOCKER UPDATE CHUNK ##############################################
# Run bookdown rendering
- name: Run bookdown render
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
jhudsl/course_template \
Rscript -e "bookdown::render_book('index.Rmd')"
##### If you do not wish to host your course on Coursera, you can delete this section #####
# Run Coursera version
- name: Run Coursera version of render
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
jhudsl/course_template \
Rscript -e "leanbuild::render_coursera()"
##### End of Coursera rendering section ########################################
# Commit the rendered bookdown files
- name: Commit rendered bookdown files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add -A
git add --force docs/*
git commit -m 'Render bookdown' || echo "No changes to commit"
git push origin main || echo "No changes to push"