Skip to content

Commit b1b2cae

Browse files
committed
Improve r environment updating: Lock r version and faster package updating
1 parent 083d01d commit b1b2cae

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

.github/workflows/custom-pages.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
1-
name: Custom GitHub Pages Build and Deploy
1+
name: Build-and-Deploy
22

33
on:
44
push:
5-
branches:
6-
- test # or any branch you want to test on
7-
workflow_dispatch: # optional, for manual triggering
5+
branches: [ test ]
6+
workflow_dispatch:
87

98
jobs:
109
build:
1110
runs-on: ubuntu-latest
11+
1212
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
14+
15+
- uses: r-lib/actions/setup-r@v2 # freeze R
16+
with: { r-version: "4.4.2" }
17+
18+
- uses: r-lib/actions/setup-pandoc@v2 # Quarto needs Pandoc
1519

16-
- name: Set up R
17-
uses: r-lib/actions/setup-r@v2
20+
- uses: quarto-dev/quarto-actions/setup@v2
21+
22+
# speed: reuse compiled packages
23+
- name: Cache renv packages
24+
uses: actions/cache@v4
25+
with:
26+
path: |
27+
~/.cache/R/renv
28+
renv/cache
29+
key: ${{ runner.os }}-renv-${{ hashFiles('renv.lock') }}
30+
restore-keys: ${{ runner.os }}-renv-
1831

19-
- name: Set up Quarto
20-
uses: quarto-dev/quarto-actions/setup@v2
32+
# restore packages exactly as in renv.lock
33+
- name: Restore R packages
34+
run: Rscript -e 'renv::restore(prompt = FALSE)'
2135

22-
# Restore R dependencies using renv (if you're using renv)
23-
- name: Restore R dependencies with renv
24-
run: Rscript -e 'renv::restore()'
25-
26-
# Render your Quarto site; output will go into the docs folder
27-
- name: Render site with Quarto
36+
# build the site
37+
- name: Render site
2838
run: quarto render
2939

30-
# Debug step: List files in the docs directory to verify rendering
31-
- name: List rendered files
40+
- name: List rendered files # optional debug
3241
run: ls -la docs
3342

34-
# Deploy the rendered site to GitHub Pages (using gh-pages branch)
35-
- name: Deploy to GitHub Pages
43+
# deploy
44+
- name: Deploy
3645
uses: peaceiris/actions-gh-pages@v3
3746
with:
3847
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)