Skip to content

Commit 4cc3970

Browse files
macromeerclaude
andcommitted
Publish the dashboard on GitHub Pages with Shinylive
A new workflow builds app/ as a Shinylive app (R runs in the visitor's browser via webR) and deploys it to GitHub Pages on every push to main. It copies app.R, R/figure.R, data/ and images/ into one folder, exports it with shinylive::export() and checks that the export contains the webR packages the figure needs: shinylive leaves out packages that are not installed where it runs. Pull requests only build and check. The README links the online app and shows a screenshot. .gitignore covers the build folders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 070b0ad commit 4cc3970

4 files changed

Lines changed: 86 additions & 0 deletions

File tree

‎.github/workflows/pages.yaml‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: pages
2+
3+
# Builds the dashboard (app/) as a Shinylive app, which runs R in the visitor's browser,
4+
# and publishes it on GitHub Pages
5+
# Pull requests only build and check the export; deploying happens from main.
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# one deployment at a time; a newer push waits instead of cancelling a running deployment
18+
concurrency:
19+
group: pages
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
env:
26+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
27+
28+
steps:
29+
- uses: actions/checkout@v7
30+
31+
- uses: r-lib/actions/setup-r@v2
32+
with:
33+
use-public-rspm: true
34+
35+
# shinylive bundles only packages that are installed here, so install all of the app's
36+
# (the suggested ones in DESCRIPTION) plus shinylive itself
37+
- uses: r-lib/actions/setup-r-dependencies@v2
38+
with:
39+
dependencies: '"all"'
40+
extra-packages: any::shinylive
41+
42+
# the app finds R/figure.R, data/ and images/ next to app.R in the bundle
43+
- name: Assemble the app
44+
run: |
45+
mkdir -p _build/app/R
46+
cp app/app.R _build/app/
47+
cp R/figure.R _build/app/R/
48+
cp -r data images _build/app/
49+
50+
- name: Export with Shinylive
51+
run: Rscript -e 'shinylive::export("_build/app", "_site", template_params = list(title = "Scientific figure dashboard"))'
52+
53+
- name: Check the export
54+
run: |
55+
test -f _site/index.html
56+
test -f _site/app.json
57+
for pkg in ggplot2 patchwork magick ragg svglite; do
58+
test -d "_site/shinylive/webr/packages/$pkg" || { echo "$pkg was not bundled"; exit 1; }
59+
done
60+
61+
- uses: actions/configure-pages@v6
62+
if: github.ref == 'refs/heads/main'
63+
64+
- uses: actions/upload-pages-artifact@v5
65+
if: github.ref == 'refs/heads/main'
66+
with:
67+
path: _site
68+
69+
deploy:
70+
needs: build
71+
if: github.ref == 'refs/heads/main'
72+
runs-on: ubuntu-latest
73+
environment:
74+
name: github-pages
75+
url: ${{ steps.deployment.outputs.page_url }}
76+
77+
steps:
78+
- id: deployment
79+
uses: actions/deploy-pages@v5

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# dashboard build (see .github/workflows/pages.yaml)
2+
_build/
3+
_site/

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ install.packages(c("shiny", "bslib", "ragg"))
3030
shiny::runApp("app")
3131
```
3232

33+
The app is also online at **https://meer.solutions/scifig_plot_examples_R/**, built with [Shinylive](https://posit-dev.github.io/r-shinylive/) and published by a GitHub Actions workflow on every push to `main`. It runs R in your browser (WebAssembly), so nothing needs to be installed and uploaded data stay on your computer. The first visit downloads about 120 MB; after that, the browser cache makes it faster.
34+
35+
![dashboard](dashboard.png)
36+
3337
## Layout
3438

3539
| Path | Contents |

‎dashboard.png‎

269 KB
Loading

0 commit comments

Comments
 (0)