1
1
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2
2
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3
3
#
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
5
8
on :
6
9
push :
7
- branches : [dev, main ]
10
+ branches : [main, dev ]
8
11
pull_request :
9
- branches : [dev, main ]
12
+ branches : [main, dev ]
10
13
release :
11
14
types : [published]
12
15
workflow_dispatch :
23
26
group : pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
24
27
env :
25
28
GITHUB_PAT : ${{ secrets.GITHUB_TOKEN }}
29
+ DELPHI_EPIDATA_KEY : ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}
26
30
steps :
27
31
- uses : actions/checkout@v3
28
32
@@ -34,19 +38,31 @@ jobs:
34
38
35
39
- uses : r-lib/actions/setup-r-dependencies@v2
36
40
with :
37
- extra-packages : any::pkgdown, local::.
41
+ extra-packages : any::pkgdown, local::., any::cli
38
42
needs : website
39
43
40
44
- name : Build site
41
- env :
42
- DELPHI_EPIDATA_KEY : ${{ secrets.SECRET_EPIPROCESS_GHACTIONS_DELPHI_EPIDATA_KEY }}
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
43
52
run : |
44
- if (startsWith("${{ github.event_name }}", "pull_request")) {
45
- mode <- ifelse("${{ github.base_ref }}" == "main", "release", "devel")
53
+ target_ref <- "${{ github.event_name == 'pull_request' && github.base_ref || github.ref }}"
54
+ override <- if (target_ref == "main") {
55
+ list(development = list(mode = "release", version_label = "light"))
56
+ } else if (target_ref == "dev") {
57
+ list(development = list(mode = "devel", version_label = "success"))
46
58
} else {
47
- mode <- ifelse("${{ github.ref_name }}" == "main", "release", "devel" )
59
+ stop("Unexpected target_ref: ", target_ref )
48
60
}
49
- pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, override=list(PKGDOWN_DEV_MODE=mode))
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)
50
66
shell : Rscript {0}
51
67
52
68
- name : Deploy to GitHub pages 🚀
0 commit comments