Skip to content

Commit

Permalink
Merge 4a7ecfd into 8ecbda9
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy authored Feb 9, 2022
2 parents 8ecbda9 + 4a7ecfd commit 87c94e8
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 180 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/check-quizzes.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

# Candace Savonen Jan 2022

name: Check Leanpub Quizzes

#---TRIGGER-START---#
on:
workflow_dispatch:
### UNCOMMENT THIS SECTION IF YOU WISH PREPARE YOUR COURSE QUIZZES FOR LEANPUB AUTOMATICALLY
# pull_request:
# branches: [ main, staging]
# paths:
# - 'quizzes/*'
######### END OF SECTION #########
pull_request:
branches: [ main, staging ]
paths:
- 'quizzes/*'
#---TRIGGER-END----#

jobs:
check-quizzes:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/delete-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

name: Delete Preview

#---TRIGGER-START---#
on:
pull_request:
types: [closed]
#---TRIGGER-END---#

jobs:
build-all:
delete-preview:
runs-on: ubuntu-latest
steps:

Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
# This code was originally written by Josh Shapiro
# 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
# Candace Savonen Apr 2021

# Adapted for this jhudsl repository by Candace Savonen Apr 2021
name: Build of Docker

name: Test build of Dockerfile

# Controls when the action will run. Triggers the workflow for a pull request for
# master
#---TRIGGER-START---#
on:
release:
types:
- created
pull_request:
branches:
- 'main'
branches: [ main, staging ]
paths: [ docker/Dockerfile, docker/github_package_list.tsv ]
workflow_dispatch:
inputs:
dockerhubpush:
description: 'Push to Dockerhub?'
required: true
default: 'false'
#---TRIGGER-END----#

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
build-docker:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: checkout repo
uses: actions/checkout@v2

- name: login as jhudsl-robot
- name: Login as jhudsl-robot
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

name: Release note PR comment

#---TRIGGER-START---#
on:
pull_request:
branches: [ main ]
branches: [ main, staging ]
types: [ opened ]
#---TRIGGER-END----#

jobs:
pr-comment:
Expand Down
86 changes: 16 additions & 70 deletions .github/workflows/render-bookdown.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,36 @@

# 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
# Candace Savonen Apr 2021

# Adapted for this jhudsl repository by Candace Savonen Apr 2021
name: Render Bookdown

name: Render Bookdown and Coursera

# Controls when the action will run. Triggers the workflow on push
# events only for the master branch
#---TRIGGER-START---#
on:
workflow_dispatch:
push:
branches: [ main ]
branches: [ main, staging ]
paths:
- '**.Rmd'
- docker/*
- assets/*
#---TRIGGER-END----#

jobs:
# This workflow contains a single job called "build-all"
render-main:
render-bookdown:
runs-on: ubuntu-latest
container:
image: jhudsl/course_template

# 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 ##############################################

- name: Login as jhudsl-robot
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
# We want a fresh run of the renders each time
- name: Delete old docs/*
run: rm -r docs/*
Expand All @@ -75,33 +39,15 @@ jobs:
- name: Run bookdown render
id: bookdown
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
--user "$(id -u):$(id -g)" \
jhudsl/course_template \
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all');
file.copy(from = 'assets', to = 'docs/assets', overwrite = TRUE)"
##### 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
id: coursera
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
--user "$(id -u):$(id -g)" \
jhudsl/course_template \
Rscript -e "ottr::render_coursera()"
##### End of Coursera rendering section ########################################

# This checks on the steps before it and makes sure that they completed.
# If the renders didn't complete we don't want to commit the file changes
- name: Check on render steps
if: steps.bookdown.outcome != 'success' || steps.coursera.outcome != 'success'
- name: Check on render step
if: steps.bookdown.outcome != 'success'
run: |
echo Bookdown status ${{steps.bookdown.outcome}}
echo Coursera status ${{steps.coursera.outcome}}
exit 1
# Commit the rendered bookdown files
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/render-coursera.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

# Candace Savonen Apr 2021

name: Render Coursera

#---TRIGGER-START---#
on:
workflow_dispatch:
workflow_run:
workflows: [ "Render Bookdown" ]
branches: [ main, staging ]
types:
- completed
#---TRIGGER-END----#

jobs:
render-coursera:
runs-on: ubuntu-latest
container:
image: jhudsl/course_template

steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}

- name: Login as jhudsl-robot
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
# Run Coursera version
- name: Run Coursera version of render
id: coursera
run: Rscript -e "ottr::render_coursera(convert_quizzes = TRUE)"

# This checks on the steps before it and makes sure that they completed.
# If the renders didn't complete we don't want to commit the file changes
- name: Check on render steps
if: steps.coursera.outcome != 'success'
run: |
echo Coursera status ${{steps.coursera.outcome}}
exit 1
# Commit the rendered bookdown files
- name: Commit rendered Coursera files
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add --force docs/coursera/*
git commit -m 'Render Coursera' || echo "No changes to commit"
git push origin main || echo "No changes to push"
43 changes: 19 additions & 24 deletions .github/workflows/render-leanpub.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@

# Jan 2022 Candace Savonen

name: Render and publish Leanpub
name: Render Leanpub

#---TRIGGER-START---#
on:
workflow_dispatch:
### UNCOMMENT THIS SECTION IF YOU WISH PREPARE YOUR COURSE FOR LEANPUB AUTOMATICALLY
# workflows: [ "Render Bookdown and Coursera" ]
# branches: [ main ]
# types:
# - completed
# paths:
# - '**.Rmd'
# - docker/*
# - assets/*
# - quizzes/*
######### END OF SECTION #########
workflow_run:
workflows: [ "Render Coursera" ]
branches: [ main, staging ]
types:
- completed
#---TRIGGER-END----#

jobs:
# This workflow contains a single job called "build-all"
render-main:
render-leanpub:
runs-on: ubuntu-latest
container:
image: jhudsl/ottr

# 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 }}

# Run leanpub rendering
- name: Login as jhudsl-robot
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
# Create screenshots
- name: Run the screenshot creation
run: |
chapt_urls=$(Rscript --vanilla scripts/make_screenshots.R \
--git_pat ${{ secrets.GH_PAT }} \
--repo $GITHUB_REPOSITORY)
# We want a fresh run of the renders each time
- name: Delete old manuscript/
run: rm -rf manuscript/

# Run Leanpub rendering
- name: Run ottr::bookdown_to_embed_leanpub
run: |
rm -rf manuscript
Rscript -e "ottr::bookdown_to_embed_leanpub( \
chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \
make_book_txt = TRUE)"
# Convert quizzes to Coursera format
- name: Convert quizzes to coursera
run: Rscript -e "ottr::render_coursera(convert_quizzes = TRUE)"

# Commit the rendered leanpub files
- name: Commit rendered leanpub files
run: |
Expand Down
Loading

0 comments on commit 87c94e8

Please sign in to comment.