55# update the documentation web site on pushes to `dev` branch.
66on :
77 push :
8- branches : [main]
8+ branches : [main, dev ]
99 pull_request :
10- branches : [main]
10+ branches : [main, dev ]
1111 release :
1212 types : [published]
1313 workflow_dispatch :
@@ -16,16 +16,17 @@ name: pkgdown
1616
1717jobs :
1818 pkgdown :
19+ # only build docs on the main repository and not forks
1920 if : github.repository_owner == 'cmu-delphi'
2021 runs-on : ubuntu-latest
2122 # Only restrict concurrency for non-PR jobs
2223 concurrency :
2324 group : pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
2425 env :
2526 GITHUB_PAT : ${{ secrets.GITHUB_TOKEN }}
26- DELPHI_EPIDATA_KEY : ${{ secrets.DELPHI_GITHUB_ACTIONS_EPIDATA_API_KEY }}
27+ DELPHI_EPIDATA_KEY : ${{ secrets.SECRET_EPIDATR_GHACTIONS_DELPHI_EPIDATA_KEY }}
2728 steps :
28- - uses : actions/checkout@v3
29+ - uses : actions/checkout@v4
2930
3031 - uses : r-lib/actions/setup-pandoc@v2
3132
@@ -35,18 +36,36 @@ jobs:
3536
3637 - uses : r-lib/actions/setup-r-dependencies@v2
3738 with :
38- extra-packages : any::pkgdown, local::.
39+ extra-packages : any::pkgdown, local::., any::cli
3940 needs : website
4041
4142 - name : Build site
42- env :
43- DELPHI_EPIDATA_KEY : ${{ secrets.SECRET_EPIDATR_GHACTIONS_DELPHI_EPIDATA_KEY }}
44- run : pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
43+ # - target_ref gets the ref from a different variable, depending on the event
44+ # - override allows us to set the pkgdown mode and version_label
45+ # - mode: release is the standard build mode, devel places the site in /dev
46+ # - version_label: 'light' and 'success' are CSS labels for Bootswatch: Cosmo
47+ # https://bootswatch.com/cosmo/
48+ # - we use pkgdown:::build_github_pages to build the site because of an issue in pkgdown
49+ # https://github.com/r-lib/pkgdown/issues/2257
50+ run : |
51+ target_ref <- "${{ github.event_name == 'pull_request' && github.base_ref || github.ref }}"
52+ override <- if (target_ref == "main" || target_ref == "refs/heads/main") {
53+ list(development = list(mode = "release"))
54+ } else if (target_ref == "dev" || target_ref == "refs/heads/dev") {
55+ list(development = list(mode = "devel"))
56+ } else {
57+ stop("Unexpected target_ref: ", target_ref)
58+ }
59+ pkg <- pkgdown::as_pkgdown(".", override = override)
60+ cli::cli_rule("Cleaning files from old site...")
61+ pkgdown::clean_site(pkg)
62+ pkgdown::build_site(pkg, preview = FALSE, install = FALSE, new_process = FALSE)
63+ pkgdown:::build_github_pages(pkg)
4564 shell : Rscript {0}
4665
4766 - name : Deploy to GitHub pages 🚀
4867 if : github.event_name != 'pull_request'
49- uses : JamesIves/github-pages-deploy-action@v4.4.1
68+ uses : JamesIves/github-pages-deploy-action@v4.5.0
5069 with :
5170 clean : false
5271 branch : gh-pages
0 commit comments