11# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33#
4- # Created with usethis + edited to run on PRs to dev, use API key.
4+ # Modifications:
5+ # * workflow_dispatch added to allow manual triggering of the workflow
6+ # * trigger branches changed
7+ # * API key secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY
58on :
69 push :
7- branches : [main, master ]
10+ branches : [main, dev ]
811 pull_request :
9- branches : [main, master, dev]
12+ branches : [main, dev]
1013 release :
1114 types : [published]
1215 workflow_dispatch :
2326 group : pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
2427 env :
2528 GITHUB_PAT : ${{ secrets.GITHUB_TOKEN }}
29+ DELPHI_EPIDATA_KEY : ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}
2630 steps :
2731 - uses : actions/checkout@v3
2832
@@ -34,13 +38,31 @@ jobs:
3438
3539 - uses : r-lib/actions/setup-r-dependencies@v2
3640 with :
37- extra-packages : any::pkgdown, local::.
41+ extra-packages : any::pkgdown, local::., any::cli
3842 needs : website
3943
4044 - name : Build site
41- env :
42- DELPHI_EPIDATA_KEY : ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}
43- run : pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
45+ # - target_ref gets the ref from a different variable, depending on the event
46+ # - override allows us to set the pkgdown mode and version_label
47+ # - mode: release is the standard build mode, devel places the site in /dev
48+ # - version_label: 'light' and 'success' are CSS labels for Bootswatch: Cosmo
49+ # https://bootswatch.com/cosmo/
50+ # - we use pkgdown:::build_github_pages to build the site because of an issue in pkgdown
51+ # https://github.com/r-lib/pkgdown/issues/2257
52+ run : |
53+ target_ref <- "${{ github.event_name == 'pull_request' && github.base_ref || github.ref }}"
54+ override <- if (target_ref == "main" || target_ref == "refs/heads/main") {
55+ list(development = list(mode = "release", version_label = "light"))
56+ } else if (target_ref == "dev" || target_ref == "refs/heads/dev") {
57+ list(development = list(mode = "devel", version_label = "success"))
58+ } else {
59+ stop("Unexpected target_ref: ", target_ref)
60+ }
61+ pkg <- pkgdown::as_pkgdown(".", override = override)
62+ cli::cli_rule("Cleaning files from old site...")
63+ pkgdown::clean_site(pkg)
64+ pkgdown::build_site(pkg, preview = FALSE, install = FALSE, new_process = FALSE)
65+ pkgdown:::build_github_pages(pkg)
4466 shell : Rscript {0}
4567
4668 - name : Deploy to GitHub pages 🚀
0 commit comments