|
1 |
| -name: Custom GitHub Pages Build and Deploy |
| 1 | +name: Build-and-Deploy |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | 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: |
8 | 7 |
|
9 | 8 | jobs:
|
10 | 9 | build:
|
11 | 10 | runs-on: ubuntu-latest
|
| 11 | + |
12 | 12 | 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 |
15 | 19 |
|
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- |
18 | 31 |
|
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)' |
21 | 35 |
|
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 |
28 | 38 | run: quarto render
|
29 | 39 |
|
30 |
| - # Debug step: List files in the docs directory to verify rendering |
31 |
| - - name: List rendered files |
| 40 | + - name: List rendered files # optional debug |
32 | 41 | run: ls -la docs
|
33 | 42 |
|
34 |
| - # Deploy the rendered site to GitHub Pages (using gh-pages branch) |
35 |
| - - name: Deploy to GitHub Pages |
| 43 | + # deploy |
| 44 | + - name: Deploy |
36 | 45 | uses: peaceiris/actions-gh-pages@v3
|
37 | 46 | with:
|
38 | 47 | github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
0 commit comments