Style your R package components automatically by running devtools::document(), styler::style_pkg(), and usethis::use_tidy_description().

use_doc_and_style_r(
  workflow_name = "call-doc-and-style-r.yml",
  use_rm_dollar_sign = FALSE,
  how_to_commit = c("pull_request", "directly"),
  build_trigger = c("push_to_main", "pull_request", "manually", "weekly"),
  use_pat = FALSE,
  pat_name = "PAT"
)

Arguments

workflow_name

What to name the github action workflow locally. Must have the file extension .yml

use_rm_dollar_sign

in addition to devtools::document and styler::style_pkg, should ghactions4r::rm_dollar_sign be run? Defaults to FALSE.

how_to_commit

Where should changes made to style and documentation be committed? Options are 1) in a pull request to the branch ("pull_request") where the workflow started; or 2) directly to the branch ("directly") where the workflow started.

build_trigger

Select the build trigger. Options are to run on pushing commits to main ("push_to_main", the default); run when a pull request is opened, reopened, or updated ("pull_request"); run manually with the workflow_dispatch trigger ("manually"); run on the default branch (usually main) once a week ("weekly").

use_pat

Should a personal access token (PAT) stored as a github secret be used? This is only necessary if you want the pull request generated by the doc and style workflow to be able to start other github action runs.

pat_name

Name of the personal access token (PAT), as stored in secrets. Only used if use_pat = TRUE. After generating the personal access token, See how to add it as a secret.

Details

Note that allow the pull request created from this workflow can be used to trigger github action runs, by using a personal access token to provide the right permissions. The PAT is first generated on a user account, then added to the repository or organization as a secret. Using a PAT can cause recursive runs, so should be used with caution. See github documentation on triggering a workflow from a workflow for more information.

Examples

# set up running the doc and style workflow on each push to main, opening a
# pull request to main when changes are found.
if (FALSE) { # \dontrun{
use_doc_and_style_r()
} # }
# the same as
if (FALSE) { # \dontrun{
use_doc_and_style_r(
  how_to_commit = "pull_request",
  build_trigger = "push_to_main"
)
} # }
# Set up running doc and style on each pull request, commiting directly to
# the pull request branch
if (FALSE) { # \dontrun{
use_doc_and_style_r(
  how_to_commit = "directly",
  build_trigger = "pull_request"
)
} # }
# Set up the workflow to use a personal access token (PAT)
if (FALSE) { # \dontrun{
use_doc_and_style_r(use_pat = TRUE, pat_name = "PAT")
} # }