generated from jhudsl/OTTR_Template_Website
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (74 loc) · 2.77 KB
/
render-site.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
# It was adapted by Candace Savonen for the OTTR_template https://github.com/jhudsl/OTTR_Template.
# This code was adapted by Carrie Wright to enable automated rendering of the site associated with this repository
# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 6) (Sunday=0 or 7)
# | | | | |
# * * * * * command to be executed
name: Render html
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * 0"
push:
branches:
- main
paths:
- '**.Rmd'
- collection.tsv
jobs:
build-collection:
name: Build Collection
uses: ./.github/workflows/build-collection.yml
with:
render-type: 'main'
repository: $GITHUB_REPOSITORY
secrets:
gh_pat: ${{ secrets.GH_PAT }}
render-main:
runs-on: ubuntu-latest
# install.packages("remotes") # in case we decide not to go with the container...
# remotes::install_cran("rmarkdown")
# remotes::install_deps(dependencies = TRUE)
needs: build-collection
container:
image: jhudsl/base_ottr:tidy4.3.2
# 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@v4
with:
# get the full repo
fetch-depth: 0
# use github PAT
token: ${{ secrets.GH_PAT }}
# We want a fresh run of the renders each time
- name: Delete old docs/*
run: rm -rf docs/*
# Now we want to render Rmd -> html
- name: Convert Rmd to html
id: bookdown
run: |
Rscript scripts/build.R
# Run TOC-less version
# Rendered content for Leanpub and Coursera is very similar.
# This job creates a shared scaffold for both.
- name: Run TOC-less version of render
id: tocless
run: Rscript -e "devtools::install_github('jhudsl/ottrpal', ref = remotes::github_pull('124'), upgrade = 'never'); ottrpal::render_without_toc()"
env:
GITHUB_PAT: ${{ secrets.gh_pat }}
# Commit the rendered site files - html files and site_libs files
- name: Commit rendered site files
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git config --global pull.ff true
git add . --force
git commit -m 'Render site' || echo "No changes to commit"
git pull --allow-unrelated-histories --strategy-option=ours
git push origin main || echo "No changes to push"