Skip to content

Commit

Permalink
[setup-r-dependencies]: install quarto if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Aug 1, 2024
1 parent f4937e0 commit 9796509
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
16 changes: 12 additions & 4 deletions setup-r-dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ Inputs available
- `extra-packages` - One or more extra package references to install.
Separate each reference by newlines or commas for more than one package.
- `install-pandoc` - Whether to install pandoc. By default it is installed
if it is not already on the PATH and the R package depends in rmarkdown.
if it is not already on the PATH and the R package depends on rmarkdown.
- `install-quarto` - Whether to install quarto. If it is 'auto' (the
default), it is installed if there is at least one `.qmd` file in the
repository, inside `working-directory`. Set to 'true' to always install
it. Set to 'false' to never install it.
- `needs` - `Config/Needs` fields to install from the DESCRIPTION, the
`Config/Needs/` prefix will be automatically included.
- `lockfile-create-lib` - The package library to consider when creating
Expand All @@ -44,11 +48,15 @@ Inputs available
install. The default installs the dependencies of the package in the
working directory and the sessioninfo package. Separate multiple packages
by newlines or commas.
- `pak-version`: Which pak version to use. Possible values are
- `pak-version` - Which pak version to use. Possible values are
`stable`, `rc` and `devel`. Defaults to `stable`.
- `pandoc-version`: Which pandoc version to install (see the
- `pandoc-version` - Which pandoc version to install (see the
`r-lib/actions/setup-pandoc` action), if pandoc is installed.
- `upgrade`: Whether to install the latest available versions of the
- `quarto-version` - Version of quarto to install, if quarto is installed.
It is passed to the `quarto-dev/quarto-actions/setup@v2` action. The
default is 'release' to install the latest release. Other possible values
are a version number number (without the `v` prefix), and 'pre-release'.
- `upgrade` - Whether to install the latest available versions of the
dependencies. Must be an R expression. See the README for details if
you need quoting. Defaults to `FALSE`.
- `working-directory` - default `'.'`. If the DESCRIPTION file is not in the
Expand Down
34 changes: 34 additions & 0 deletions setup-r-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ s.'
pandoc-version:
description: 'Pandoc version to install.'
default: '3.1.11'
install-quarto:
description: |
Whether to install quarto. If it is 'auto' (the default), it is
installed if there is at least one `.qmd` file in the repository,
inside `working-directory`. Set to 'true' to always install it.
Set to 'false' to never install it.
default: 'auto'
quarto-version:
description: |
Version of quarto to install, if quarto is installed. It is passed
to the `quarto-dev/quarto-actions/setup@v2` action. The default is
'release' to install the latest release. Other possible values are
a version number number (without the `v` prefix), and 'pre-release'.
default: 'release'
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -183,6 +197,26 @@ runs:
with:
pandoc-version: ${{ inputs.pandoc-version }}

- name: Check whether quarto if needed
id: check-quarto
run: |
cat("::group::Check if package needs quarto\n")
if (length(dir(recursive = TRUE, pattern = "[.]qmd$")) > 0) {
o <- "true"
} else {
o <- "false"
}
cat("install=", o, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
cat("::endgroup::\n")
shell: Rscript {0}
working-directory: R{{ inputs.working-directory }}

- name: Install quarto if needed
if: ${{ steps.check-quarto.outputs.install == 'true' }}
uses: quarto-dev/quarto-actions/setup@v2
with:
version: ${{ inputs.quarto-version }}

- name: Session info
run: |
# Session info
Expand Down

0 comments on commit 9796509

Please sign in to comment.