Skip to content

Commit e282b24

Browse files
authored
Actions v2 (#19)
revamp actions and documentation for v2
1 parent 3c7c775 commit e282b24

16 files changed

+349
-205
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
This repository stores [Github Actions](https://github.com/features/actions) around Quarto (https://quarto.org/)
44

5-
1. [quarto-dev/quarto-actions/install-quarto](https://github.com/quarto-dev/quarto-actions/tree/master/install-quarto) - Install Quarto binary
5+
1. [quarto-dev/quarto-actions/setup](https://github.com/quarto-dev/actions/tree/master/setup) - Install Quarto
6+
2. [quarto-dev/quarto-actions/render](https://github.com/quarto-dev/actions/tree/master/render) - Render project
7+
3. [quarto-dev/quarto-actions/publish](https://github.com/quarto-dev/actions/tree/master/publish) - Publish project
8+
9+
We recommend using `v2` for your actions, and our examples all use `v2`.
610

711
## Examples
812

@@ -14,11 +18,5 @@ This repository is using [recommended release management for actions](https://do
1418

1519
* Github releases with tags are used for updates on the actions.
1620
* Semantic versioning is used, with major, minor and possibly patch release.
17-
* Major version (such as `v1`) will always point to the last minor or patch release for this major version. (when `v1.0.2` is out, `v1` will point to this update to). This means using `quarto-dev/quarto-actions/install-quarto@v1` in your workflow file will automatically get the updated versions. Using `quarto-dev/quarto-actions/[email protected]` will pin a specific release.
18-
* Major version change (`v1` to `v2`) will often come with a possible breaking change, and a workflow would require manual update.
19-
20-
Example:
21-
22-
```yaml
23-
- uses: quarto-dev/quarto-actions/install-quarto@v1
24-
```
21+
* Major version (such as `v1`) will always point to the last minor or patch release for this major version. (when `v1.0.2` is out, `v1` will point to this update to). This means using `quarto-dev/quarto-actions/setup@v2` in your workflow file will automatically get the updated versions. Using `quarto-dev/quarto-actions/[email protected]` will pin a specific release.
22+
* Major version change (`v1` to `v2`) will often come with a possible breaking change, and a workflow would require manual update.

examples/README.md

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,14 @@
1-
# Examples of workflow YAML files
1+
# Using Quarto Actions: Examples
22

3-
You'll find here some generic workflows for Quarto projects.
3+
* [Basics](./example-01-basics.md)
4+
* [Freeze](./example-02-freeze.md)
5+
* [Other dependencies](./example-03-other-dependencies.md)
46

5-
## Templates
6-
7-
### Quarto Book
8-
9-
- [`quarto-book-gh-pages`](./quarto-book-gh-pages.yaml): Render an HTML Quarto Book and deploy to github pages
10-
11-
- [`quarto-book-netlify`](./quarto-book-netlify.yaml): Render an HTML Quarto Book and deploy to [Netlify](https://www.netlify.com). You must also config 2 github secrets:
12-
- `NETLIFY_AUTH_TOKEN`: [Personal access tokens](https://app.netlify.com/user/applications#personal-access-tokens) > New access token
13-
- `NETLIFY_SITE_ID`: team page > your site > Settings > Site details > Site information > API ID
14-
- More details see [this Netlify action](https://github.com/nwtgck/actions-netlify).
15-
16-
### How to use ?
17-
18-
1. Download one of the YAML workflows into the `.github/workflows` folder of your project where [Github Actions Workflows](https://docs.github.com/en/actions/quickstart) are stored
19-
2. Edit the workflow file according to your needs, especially adding steps to setup any computation engines you may need (Python, R, Julia, ...).
20-
21-
See the repository examples using Quarto actions below.
22-
23-
#### Specific for R users
24-
25-
With the [**usethis**](https://usethis.r-lib.org/) package, R users can easily add one of these example workflow in a project using [`usethis::use_github_action()`](https://usethis.r-lib.org/reference/github_actions.html) and the full URL of the raw YAML file. Example (where `v1` indicates the version tag):
26-
27-
```r
28-
usethis::use_github_action(
29-
url = "https://raw.githubusercontent.com/quarto-dev/quarto-actions/v1/examples/quarto-book-gh-pages.yaml"
30-
)
31-
```
32-
33-
This will download the YAML file into the `.github/workflows/` folder of your project, where it can be further adapted to your project (like adding a step to install R and R dependencies).
347

358
## Repositories using Quarto actions
369

37-
- [Earthdata Cloud Cookbook](https://nasa-openscapes.github.io/earthdata-cloud-cookbook/) ([source](https://github.com/NASA-Openscapes/earthdata-cloud-cookbook)). Book with `*.md` and `.ipynb` is built with Quarto and Python in GHA and deployed to Github Pages. [workflow file](https://github.com/NASA-Openscapes/earthdata-cloud-cookbook/blob/main/.github/workflows/quarto-render.yml).
10+
- [Earthdata Cloud Cookbook](https://nasa-openscapes.github.io/earthdata-cloud-cookbook/) ([source](https://github.com/NASA-Openscapes/earthdata-cloud-cookbook), [workflow file](https://github.com/NASA-Openscapes/earthdata-cloud-cookbook/blob/main/.github/workflows/quarto-render.yml)) This book contains `.md` and `.ipynb` files, and is built with Quarto and Python in GHA, and deployed to Github Pages.
3811

39-
- [R Manuals Quarto website](https://rstudio.github.io/r-manuals/) ([source](https://github.com/rstudio/r-manuals)) uses a complex workflow to build several books with R and Quarto and organizes them in a unique website deployed to Github pages. [workflow file](https://github.com/rstudio/r-manuals/blob/main/.github/workflows/build-website.yaml).
12+
- [R Manuals Quarto website](https://rstudio.github.io/r-manuals/) ([source](https://github.com/rstudio/r-manuals), [workflow file](https://github.com/rstudio/r-manuals/blob/main/.github/workflows/build-website.yaml)) This projects uses a workflow to build several books with R and Quarto and organizes them in a website deployed to Github pages.
4013

41-
- [Pathology Atlas](https://www.patolojiatlasi.com/EN) is a multilingual website ([source](https://github.com/patolojiatlasi/patolojiatlasi.github.io)). Two versions are rendered and deployed using Github Action. [workflow file](https://github.com/patolojiatlasi/patolojiatlasi.github.io/blob/main/.github/workflows/Quarto-Render-Bilingual-Book-Push-Tweet-Updates.yml)
14+
- [Pathology Atlas](https://www.patolojiatlasi.com/EN) ([source](https://github.com/patolojiatlasi/patolojiatlasi.github.io), [workflow file](https://github.com/patolojiatlasi/patolojiatlasi.github.io/blob/main/.github/workflows/Quarto-Render-Bilingual-Book-Push-Tweet-Updates.yml)) This multilingual website is rendered in two versions and deployed using Github Actions.

examples/example-01-basics.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Quarto Actions: Basics
2+
3+
The simplest workflow using Quarto Actions uses the `setup` and `publish` actions: [quarto-publish-example.yml](quarto-publish-example.yml).
4+
5+
## GitHub Pages
6+
7+
1. **Add the GitHub Actions workflow to your project**
8+
9+
Copy [quarto-publish-example.yml](quarto-publish-example.yml) to `.github/workflows/quarto-publish.yml`. Uncomment the "Publish to GitHub Pages (and render)" action. No further changes are needed to the action (in particular, do *not* edit the line below to add a secret to this file. This file has the same permissions as your repository, and might be publicly readable)
10+
11+
Now, add and commit the workflow file you have just created, and push the result to GitHub. This should trigger a new action from GitHub that will automatically render and publish your website through GitHub pages. Note that this will create a `gh-pages` branch in your repository if one doesn't exist.
12+
13+
14+
## Netlify
15+
16+
1. **Create Netlify auth token**
17+
18+
Go to Netlify's [applications page](https://app.netlify.com/user/applications), and click on "New Access Token" to create a new personal access token. Give this token a memorable name, and note the resulting string (or keep this browser window open).
19+
20+
2. **Add Netlify auth token to your GitHub repository**
21+
22+
Go to the GitHub webpage for the repository that will be using this GitHub Action. Click on "Settings". On the new page, click on "Secrets", then on the dropdown "Actions". Now, on the right-hand tab, click on the "New repository secret" button to the right of the title "Actions secrets". For the "Name" field, use `NETLIFY_AUTH_TOKEN`, and for the "Value" field, paste the string you got from step 1.
23+
24+
3. **Add the GitHub Actions workflow to your project**
25+
26+
Copy [quarto-publish-example.yml](quarto-publish-example.yml) to `.github/workflows/quarto-publish.yml`.
27+
28+
Uncomment the "Publish to Netlify (and render)" action. No further changes are needed (in particular, do *not* edit the line below to add a secret to this file. This file has the same permissions as your repository, and might be publicly readable)
29+
30+
4. **Add `_publish.yml` to your repository**
31+
32+
Quarto stores publishing metadata information in `_publish.yml`. To create this file, run `quarto publish netlify` locally once (TODO: how does this work in an IDE?).
33+
34+
35+
Finally, add and commit the files you have just created, and push the result to GitHub. This should trigger a new action from GitHub that will automatically render and publish your website through Netlify.
36+
37+
## RStudio Connect
38+
39+
1. **Create RStudio Connect auth token**
40+
41+
After logging in to your RStudio Connect server, click on your username on the top right. A sidebar should slide in from the right. Click on "API keys". On the new page, click on the "New API Key" button. Give it a memorable name and note the resulting string (or keep this browser window open).
42+
43+
2. **Add RStudio Connect auth token to your GitHub repository**
44+
45+
Go to the GitHub webpage for the repository that will be using this GitHub Action. Click on "Settings". On the new page, click on "Secrets", then on the dropdown "Actions". Now, on the right-hand tab, click on the "New repository secret" button to the right of the title "Actions secrets". For the "Name" field, use `CONNECT_API_KEY`, and for the "Value" field, paste the string you got from step 1.
46+
47+
3. **Add the GitHub Actions workflow to your project**
48+
49+
Copy [quarto-publish-example.yml](quarto-publish-example.yml) to `.github/workflows/quarto-publish.yml`. Uncomment the "Publish to RStudio Connect (and render)" action, and change the CONNECT_SERVER entry to the URL of your RStudio Connect server. No further changes are needed to the action (in particular, do *not* edit the line below to add a secret to this file. This file has the same permissions as your repository, and might be publicly readable)
50+
51+
4. **Add `_publish.yml` to your repository**
52+
53+
Quarto stores publishing metadata information in `_publish.yml`. To create this file, run `quarto publish connect` locally once (TODO: how does this work in an IDE?).
54+
55+
Finally, add and commit the files you have just created, and push the result to GitHub. This should trigger a new action from GitHub that will automatically render and publish your website through RStudio Connect.
56+
57+
58+

examples/example-02-freeze.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Quarto Actions: Freeze
2+
3+
If you have computational content which cannot be executed in a CI environment (because of eg security or authentication), you can use Quarto's freezer feature.
4+
5+
## Enabling Freeze
6+
7+
Add the following to your `_quarto.yml` configuration:
8+
9+
```yaml
10+
execute:
11+
freeze: true # never re-execute computational content during project render
12+
```
13+
14+
This stops quarto from re-executing computational cells during a project render.
15+
16+
## Adding the frozen contents to the repository
17+
18+
From a computer that is capable of executing the content, run a file-specific `render` command to create or update the frozen content
19+
20+
```bash
21+
$ quarto render name-of-file-to-freeze.qmd
22+
```
23+
24+
Note that you have to specify the particular file: a call to `quarto render` will _not_ re-execute the content when `freeze: true`. Finally, add the `_freeze` top-level directory to version control so that GitHub Actions can reuse the executed content.
25+
26+
## More
27+
28+
See [Quarto's documentation on freeze](https://quarto.org/docs/projects/code-execution.html#freeze) for more.

examples/example-03-dependencies.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Quarto Actions: Dependencies
2+
3+
If you want to execute computational content in GitHub Actions workflows, you are going to have to install the necessary software dependencies in your action.
4+
5+
## Installing R
6+
7+
Add the following entry to your GitHub Actions workflow:
8+
9+
```yaml
10+
- uses: r-lib/actions/setup-r@v2
11+
with:
12+
r-version: '4.2.0' # The R version to download (if necessary) and use.
13+
```
14+
15+
If you're using `quarto-publish-example.yml`, add those right after the `# add software dependencies here` comment.
16+
17+
### renv
18+
19+
If you are managing your R package dependencies with `renv`, the following action will install the dependencies:
20+
21+
```yaml
22+
- uses: r-lib/actions/setup-renv@v2
23+
with:
24+
cache-version: 1
25+
```
26+
27+
See [the `setup-renv` documentation](https://github.com/r-lib/actions/tree/v2/setup-renv) for how to use `cache-version`.
28+
29+
## Installing Jupyter
30+
31+
Add the following entry to your GitHub Actions workflow:
32+
33+
```yaml
34+
- uses: actions/setup-python@v4
35+
with:
36+
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
37+
- run: pip install jupyter
38+
```
39+
40+
### Using `requirements.txt`
41+
42+
```yaml
43+
- uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
46+
cache: 'pip'
47+
- run: pip install jupyter # (if jupyter is not part of your requirements.txt)
48+
- run: pip install -r requirements.txt
49+
```
50+
51+
## Installing Julia
52+
53+
TBF.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Using Quarto Actions: other workflows
2+
3+
## Render without publishing
4+
5+
If you need to render your project in a GitHub Action, but will use the output for something besides publishing (or publishing to a service not supported by `quarto publish`), then use the `render` action:
6+
7+
```yaml
8+
- name: Render Quarto Project
9+
uses: quarto-dev/quarto-actions/render@v2
10+
```

examples/quarto-book-gh-pages.yaml

Lines changed: 0 additions & 42 deletions
This file was deleted.

examples/quarto-book-netlify.yaml

Lines changed: 0 additions & 49 deletions
This file was deleted.

examples/quarto-publish-example.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
on:
2+
push:
3+
branches: main
4+
5+
# TODO test PR trigger
6+
# pull_request:
7+
# branches: main
8+
9+
name: Render and Publish
10+
11+
jobs:
12+
build-deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Quarto
19+
uses: quarto-dev/quarto-actions/setup@v2
20+
with:
21+
# To install LaTeX to build PDF book
22+
tinytex: true
23+
# uncomment below and fill to pin a version
24+
# version: 0.9.600
25+
26+
# add software dependencies here
27+
28+
# To publish to Netlify, RStudio Connect, or GitHub Pages, uncomment
29+
# the appropriate block below
30+
31+
# - name: Publish to Netlify (and render)
32+
# uses: quarto-dev/quarto-actions/publish@v2
33+
# with:
34+
# to: netlify
35+
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
36+
37+
# - name: Publish to RStudio Connect (and render)
38+
# uses: quarto-dev/quarto-actions/publish@v2
39+
# with:
40+
# to: connect
41+
# CONNECT_SERVER: enter-the-server-url-here
42+
# CONNECT_API_KEY: ${{ secrets.CONNECT_API_KEY }}
43+
44+
# - name: Publish to GitHub Pages (and render)
45+
# uses: quarto-dev/quarto-actions/publish@v2
46+
# with:
47+
# to: gh-pages
48+
# env:
49+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # this secret is always available for github actions
50+

0 commit comments

Comments
 (0)