Build & Deploy Website #493
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build & Deploy Website | |
on: | |
workflow_call: | |
secrets: | |
REPO_GITHUB_TOKEN: | |
description: | | |
Github token with write access to the repository | |
required: false | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- ready_for_review | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "10 10 * * *" | |
workflow_dispatch: | |
jobs: | |
build-deploy: | |
name: Build & Deploy Website | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Cache artifacts | |
uses: actions/cache@v4 | |
with: | |
path: _freeze | |
key: ${{ runner.os }}-examples | |
- name: Set up Quarto | |
uses: quarto-dev/quarto-actions/setup@v2 | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Setup R Dependencies | |
uses: r-lib/actions/setup-r-dependencies@v2 | |
- name: Render Quarto Project | |
uses: quarto-dev/quarto-actions/render@v2 | |
with: | |
to: html | |
# temporary! | |
# remove this step if closed (& relleased): https://github.com/quarto-ext/shinylive/issues/59 | |
- name: Remove large WebR assets 🧹 | |
run: | | |
packages_path <- sprintf("./_site/site_libs/quarto-contrib/shinylive-%s/shinylive/webr/packages", shinylive::assets_version()) | |
# remove the dirs with size > 100 MB | |
for (x in list.dirs(packages_path)) { | |
x_files <- file.info(list.files(x, full.names = TRUE)) | |
if (any(x_files$size > 100 * 1024^2)) { | |
print(x) | |
print(x_files) | |
unlink(x, recursive = TRUE) | |
} | |
} | |
# refresh the `metadata.rds` file | |
metadata_path <- file.path(packages_path, "metadata.rds") | |
metadata <- readRDS(metadata_path) | |
new_metadata <- metadata[intersect(names(metadata), list.dirs(packages_path, full.names = FALSE))] | |
saveRDS(new_metadata, metadata_path) | |
shell: Rscript {0} | |
- name: Publish docs | |
if: github.ref == 'refs/heads/main' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./_site |