Skip to content

Commit fedf6ba

Browse files
committed
Create a new GitHub Actions workflow in publish-cloudflare-pages.yml; add deployment notes to README.Rmd
1 parent abd183a commit fedf6ba

File tree

2 files changed

+71
-5
lines changed

2 files changed

+71
-5
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
workflow_dispatch:
3+
push:
4+
branches: cf-pages
5+
6+
name: Publish Quarto to Cloudflare Plages
7+
8+
jobs:
9+
build-deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
deployments: write
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Quarto
19+
uses: quarto-dev/quarto-actions/setup@v2
20+
with:
21+
version: pre-release
22+
23+
# install libcurl, needed for curl R package
24+
# libfribidi-dev libharfbuzz-dev for textshaping
25+
# libxslt1-dev for xslt
26+
- name: Install R package deps
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install libcurl4-openssl-dev libfribidi-dev libharfbuzz-dev libxslt1-dev
30+
31+
- name: Install R
32+
uses: r-lib/actions/setup-r@v2
33+
with:
34+
r-version: "4.4.0"
35+
36+
- name: Install R Dependencies
37+
uses: r-lib/actions/setup-renv@v2
38+
with:
39+
cache-version: 1
40+
41+
- name: Render book
42+
run: Rscript -e 'babelquarto::render_website()'
43+
44+
- name: Deploy
45+
uses: cloudflare/wrangler-action@v3
46+
with:
47+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
48+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
49+
command: pages deploy _site --project-name=joelnitta-photos

README.Rmd

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,30 @@ knitr::opts_chunk$set(
1313

1414
# joelnitta-home
1515

16-
[![Netlify Status](https://api.netlify.com/api/v1/badges/4dec3009-d025-4fdf-b25e-76e98b2f34e1/deploy-status)](https://app.netlify.com/sites/laughing-cray-e2c0db/deploys)
17-
1816
Source code for [personal website of Joel Nitta](https://www.joelnitta.com).
1917

20-
Created with [Quarto](https://quarto.org/) in [R](https://www.r-project.org/).
18+
Created with [Quarto](https://quarto.org/) in [R](https://www.r-project.org/).
19+
20+
21+
## Production deployment
22+
23+
Production deployment is set up using GitHub Actions with [./.github/workflows/publish-cloudflare-pages.yml](./.github/workflows/publish-cloudflare-pages.yml).
24+
25+
The workflow file is very simple and basically runs two commands:
26+
27+
1. `Rscript -e 'babelquarto::render_website()'`, which compiles the Quarto blog to a static website within the `_site` folder. This folder contains an `index.html` which is the root of the website, as well as various JavaScript and CSS files and images; you can read more on [`quarto render`](https://quarto.org/docs/projects/quarto-projects.html#rendering-projects). Note that `_site` is ignored in `.gitignore` because it is generated from the source code; the source code is what we track in version control, not the built files.
28+
29+
2. `wrangler pages deploy _site --project-name=joelnitta-home`, which deploys the `_site` folder to Cloudflare Pages. You can read more details on [`wrangler pages deploy`](https://developers.cloudflare.com/workers/wrangler/commands/#deploy-1).
30+
31+
### Secrets
32+
33+
This workflow requires two secrets to be set up in GitHub:
34+
35+
- `CLOUDFLARE_API_TOKEN`: see Cloudflare docs on [how to create an API token](https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/#generate-an-api-token)
36+
- `CLOUDFLARE_ACCOUNT_ID`: see Cloudflare docs on [how to get the account ID](https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/#get-project-account-id)
37+
38+
Both secrets must be stored in the settings for the GitHub repository - see GitHub docs on [Creating secrets for a repository](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository).
2139

22-
Site built by [GitHub actions](.github/workflows/build_site.yml) to the [`gh_pages` branch](https://github.com/joelnitta/joelnitta-home/tree/gh-pages), deployed by [Netlify](https://www.netlify.com/).
2340

2441
## Local deployment
2542

@@ -48,4 +65,4 @@ Code: [MIT](LICENSE)
4865

4966
Text and images, unless otherwise indicated: Creative Commons Attribution [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/legalcode)
5067

51-
Publications (PDF files): Indicated in each publication.
68+
Publications (PDF files): Indicated in each publication.

0 commit comments

Comments
 (0)