-
Notifications
You must be signed in to change notification settings - Fork 8
72 lines (59 loc) · 2.31 KB
/
build_and_publish.yml
File metadata and controls
72 lines (59 loc) · 2.31 KB
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
name: Build and publish
on:
push:
branches: [devel] # Run this workflow only when pushing to the 'devel' branch
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full git history is available (needed for Quarto publishing)
ref: devel # Explicitly check out the 'devel' branch
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
# Fixes "dubious ownership" error when running inside container
- name: Mark repo as safe for git
run: git config --global --add safe.directory $GITHUB_WORKSPACE
# Makes sure 'gh-pages' branch exists locally so Quarto can publish to it
- name: Fetch gh-pages branch
run: git fetch origin gh-pages:gh-pages
# We could specify Quarto version, but if we want to always use the latest
# one, we need the following libraries to get the information on what is
# the latest Quarto version.
- name: Install GitHub CLI and jq
run: |
sudo apt-get update
sudo apt-get install -y gh jq
# Install Quarto
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
# Ensure that the caching directory is available
- name: Ensure R library directory exists
run: mkdir -p $R_LIBS_USER
# Cache previously installed R packages to speed up future builds
- name: Cache R packages
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ hashFiles('**/DESCRIPTION') }}
restore-keys: |
${{ runner.os }}-r-
# Install all R dependencies defined in DESCRIPTION file
- name: Install dependencies
run: |
Rscript -e "install.packages('devtools')"
Rscript -e "devtools::install_deps(dependencies = TRUE)"
# Build the Quarto project into HTML
- name: Render site
run: quarto render
# Push the rendered site to the gh-pages branch for GitHub Pages hosting
- name: Publish to GitHub Pages
uses: quarto-dev/quarto-actions/publish@v2
with:
target: gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}