-
Notifications
You must be signed in to change notification settings - Fork 6
108 lines (99 loc) · 4 KB
/
pkgdown.yml
File metadata and controls
108 lines (99 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
on:
push:
branches:
- main
- master
paths:
- 'DESCRIPTION'
- '**pkgdown.yml'
- '*.md'
- 'inst/CITATION'
- 'inst/*.bib'
- 'inst/treespace/app.R'
- 'man/**.Rd'
- 'vignettes/**.Rmd'
release:
types: [published]
workflow_dispatch:
name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
# ── Build pkgdown site (no shinylive, no deploy) ──────────────
- uses: ms609/actions/pkgdown@main
with:
extra-repositories: https://ms609.github.io/packages/
deploy: 'false'
# ── Export Shinylive app ──────────────────────────────────────
- name: Export Shinylive app
shell: Rscript {0}
run: |
# ── Locate app ──
pkg_name <- read.dcf("DESCRIPTION")[, "Package"]
app_dir <- system.file("treespace", package = pkg_name)
if (!dir.exists(app_dir)) app_dir <- "inst/treespace"
stopifnot(
"app.R not found" = file.exists(file.path(app_dir, "app.R"))
)
# ── Work around shinylive bug (coatless/quarto-webr#228) ──
# shinylive resolves deps from the WASM repo's PACKAGES
# database, which may reference packages not installed
# locally (e.g. R.cache). packageDescription() returns NA
# for these, and shinylive crashes on desc$Repository.
# Patch packageDescription to return a stub instead of NA.
#
# TODO: Remove once shinylive handles missing packages.
# TODO: Also remove remotes from DESCRIPTION/suggests/website
local({
real_pd <- utils::packageDescription
ns <- asNamespace("utils")
unlockBinding("packageDescription", ns)
assign("packageDescription", function(pkg, lib.loc = NULL,
fields = NULL, drop = TRUE, encoding = "") {
result <- real_pd(pkg, lib.loc = lib.loc, fields = fields,
drop = drop, encoding = encoding)
if (identical(result, NA)) {
message(" [shinylive patch] '", pkg,
"' not installed locally; stub description used")
result <- structure(
list(Package = pkg, Version = "0.0.0",
Repository = "CRAN"),
class = "packageDescription"
)
if (!is.null(fields)) {
result <- result[fields]
if (drop && length(fields) == 1L)
return(result[[1L]])
}
}
result
}, envir = ns)
})
# ── Export ──
tryCatch(
shinylive::export(appdir = app_dir, destdir = "docs/app",
wasm_packages = FALSE,
repos = c("https://ms609.r-universe.dev",
"https://repo.r-wasm.org")),
error = function(e) {
msg <- conditionMessage(e)
message("\n===== shinylive::export() failed =====")
message(msg)
message("This is often caused by a dependency not available")
message("as a WebAssembly binary. Check both:")
message(" https://repo.r-wasm.org/bin/emscripten/contrib/4.5/PACKAGES")
message(" https://ms609.r-universe.dev/bin/emscripten/contrib/4.5/PACKAGES")
stop(e)
}
)
file.create("docs/.nojekyll")
# ── Deploy ────────────────────────────────────────────────────
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs
branch: gh-pages
clean: false