Skip to contents

Writes a netlify.toml that names the publish directory, and a GitHub Actions workflow that builds the site and deploys it with the Netlify CLI. Netlify's own build image has no R, so the site is never built on Netlify. Every response header the site needs, cross-origin isolation included, is in the _headers file bind() writes into the site, so dropping the output directory on Netlify works too.

Usage

circulate_via_netlify(path = ".", overwrite = FALSE)

Arguments

path

Project path.

overwrite

If TRUE, replace existing files.

Value

Invisibly, the paths of the files written.

Details

The netlify.toml goes next to _webrarian.yml. The workflow goes in .github/workflows/ at the root of the collection's git repository, as for circulate_via_github(), and runs its steps in the collection's directory.

Examples

collection <- file.path(tempdir(), "webrarian-netlify-demo")
catalog(collection)
#> ✔ Created directory /tmp/RtmpQU25pJ/webrarian-netlify-demo
#> ✔ Created _webrarian.yml
#> ✔ Added "_site/" and ".webrarian/" to .gitignore
#> ✔ Cataloged webrarian collection: "webrarian-netlify-demo"
#> 
#> Next steps:
#>   Move into the collection: `setwd("/tmp/RtmpQU25pJ/webrarian-netlify-demo")`
#>   Acquire packages: `webrarian::acquire_package("dplyr")`
#>   Acquire files: `webrarian::acquire_file("data/")`
#>   Bind: `webrarian::bind()`
#>   Reading room: `webrarian::reading_room()`
#> ℹ Or pass `path` to each call, e.g. `webrarian::bind(path =
#>   "/tmp/RtmpQU25pJ/webrarian-netlify-demo")`

circulate_via_netlify(collection)
#> ! /tmp/RtmpQU25pJ/webrarian-netlify-demo is not in a git repository, so the workflow is written there. Move .github/workflows/ to the repository root when you create one.
#> ✔ Generated Netlify deployment files
#> • /tmp/RtmpQU25pJ/webrarian-netlify-demo/netlify.toml
#> • /tmp/RtmpQU25pJ/webrarian-netlify-demo/.github/workflows/netlify-deploy.yml
#> 
#> ℹ Add repository secrets `NETLIFY_AUTH_TOKEN` and `NETLIFY_SITE_ID`; the
#>   workflow deploys on every push.
#> ℹ Or deploy by hand: run `bind()` and drop _site on
#>   https://app.netlify.com/drop - its _headers file carries every header the
#>   site needs, cross-origin isolation included.

unlink(collection, recursive = TRUE)