Skip to content

Commit e2507ba

Browse files
committed
improve gha
1 parent 91a7b2c commit e2507ba

1 file changed

Lines changed: 37 additions & 53 deletions

File tree

Lines changed: 37 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# NOTE: We render the site in GitHub Actions because some pages (e.g., instructors.qmd)
2-
# require R execution to pull dynamic data from CSV files. Netlify's build environment
3-
# does not include R, so we cannot rely on the Quarto Netlify plugin for rendering.
4-
# Instead, CI installs R + Quarto, renders the site, and deploys the pre-rendered HTML
5-
# to Netlify for both PR previews and production.
1+
# NOTE:
2+
# We render the site in GitHub Actions because some pages (e.g. instructors.qmd)
3+
# require R to dynamically load data from CSV files.
4+
#
5+
# Netlify does not provide an R environment, so we cannot use the Quarto Netlify plugin.
6+
#
7+
# Instead, CI installs R + Quarto, renders the site, and deploys the
8+
# pre-rendered HTML to Netlify for both PR previews and production.
69

710
name: CI/CD
811

@@ -14,51 +17,41 @@ on:
1417
schedule:
1518
- cron: '0 1 * * 0' # every Sunday at 01:00 UTC
1619

17-
env:
18-
cache-version: v1
19-
2020
jobs:
21-
# Build & preview deploy for PRs
21+
22+
# -----------------------------
23+
# PR preview build + deploy
24+
# -----------------------------
2225
build-preview:
2326
if: github.event_name == 'pull_request'
2427
runs-on: ubuntu-latest
28+
2529
steps:
2630
- name: Check out repository
2731
uses: actions/checkout@v4
2832

2933
- name: Set up Quarto
3034
uses: quarto-dev/quarto-actions/setup@v2
3135

32-
- name: Install system dependencies
33-
run: |
34-
sudo apt-get update
35-
sudo apt-get install -y libudunits2-dev libgdal-dev libgeos-dev libproj-dev
36-
37-
- name: Cache R packages
38-
uses: actions/cache@v3
39-
with:
40-
path: ~/.R
41-
key: ${{ env.cache-version }}-${{ runner.os }}-${{ hashFiles('**/DESCRIPTION', '**/renv.lock') }}
42-
restore-keys: |
43-
${{ env.cache-version }}-${{ runner.os }}-
44-
4536
- name: Set up R
4637
uses: r-lib/actions/setup-r@v2
4738
with:
4839
use-public-rspm: true
4940

50-
- name: Install R dependencies
51-
run: |
52-
Rscript -e 'install.packages("remotes", repos = "https://cloud.r-project.org")'
53-
Rscript -e 'remotes::install_deps(dependencies = TRUE)'
41+
- name: Install R dependencies (cached)
42+
uses: r-lib/actions/setup-r-dependencies@v2
43+
with:
44+
cache: true
45+
cache-dependency-path: |
46+
DESCRIPTION
47+
renv.lock
5448
5549
- name: Render Quarto Project
5650
run: quarto render
5751

5852
- name: Deploy Preview to Netlify
5953
run: |
60-
npm install -g netlify-cli
61-
netlify deploy \
54+
npx netlify-cli deploy \
6255
--auth "$NETLIFY_AUTH_TOKEN" \
6356
--site "$NETLIFY_SITE_ID" \
6457
--dir docs \
@@ -68,46 +61,37 @@ jobs:
6861
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
6962
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
7063

71-
# Production deploy on push/schedule to devel
64+
# -----------------------------
65+
# Production deploy
66+
# -----------------------------
7267
deploy-prod:
73-
if: github.ref == 'refs/heads/devel' && (github.event_name == 'push' || github.event_name == 'schedule')
68+
if: github.ref == 'refs/heads/devel'
7469
runs-on: ubuntu-latest
70+
7571
steps:
7672
- name: Check out repository
7773
uses: actions/checkout@v4
7874

7975
- name: Set up Quarto
8076
uses: quarto-dev/quarto-actions/setup@v2
8177

82-
- name: Install system dependencies
83-
run: |
84-
sudo apt-get update
85-
sudo apt-get install -y libudunits2-dev libgdal-dev libgeos-dev libproj-dev
86-
87-
- name: Cache R packages
88-
uses: actions/cache@v3
89-
with:
90-
path: ~/.R
91-
key: ${{ env.cache-version }}-${{ runner.os }}-${{ hashFiles('**/DESCRIPTION', '**/renv.lock') }}
92-
restore-keys: |
93-
${{ env.cache-version }}-${{ runner.os }}-
94-
9578
- name: Set up R
9679
uses: r-lib/actions/setup-r@v2
9780
with:
9881
use-public-rspm: true
9982

100-
- name: Install R dependencies
101-
run: |
102-
Rscript -e 'install.packages("remotes", repos = "https://cloud.r-project.org")'
103-
Rscript -e 'remotes::install_deps(dependencies = TRUE)'
83+
- name: Install R dependencies (cached)
84+
uses: r-lib/actions/setup-r-dependencies@v2
85+
with:
86+
cache: true
87+
cache-dependency-path: |
88+
DESCRIPTION
89+
renv.lock
10490
10591
- name: Render Quarto Project
10692
run: quarto render
10793

108-
# If you still want GitHub Pages in addition to Netlify, keep this step.
109-
# Otherwise you can remove it and use Netlify as your sole host.
110-
- name: Add CNAME for GitHub Pages custom domain
94+
- name: Add CNAME for GitHub Pages
11195
run: echo "training.bioconductor.org" > docs/CNAME
11296

11397
- name: Publish to GitHub Pages (optional)
@@ -119,13 +103,13 @@ jobs:
119103

120104
- name: Deploy Production to Netlify
121105
run: |
122-
npm install -g netlify-cli
123-
netlify deploy \
106+
npx netlify-cli deploy \
124107
--auth "$NETLIFY_AUTH_TOKEN" \
125108
--site "$NETLIFY_SITE_ID" \
126109
--dir docs \
127110
--prod \
128111
--message "devel @ ${{ github.sha }}"
129112
env:
130113
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
131-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
114+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
115+

0 commit comments

Comments
 (0)