-
Notifications
You must be signed in to change notification settings - Fork 5
/
report-generator.R
executable file
·46 lines (39 loc) · 1.39 KB
/
report-generator.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env Rscript
# Location
cat(sprintf("Current dir is: '%s'", getwd()))
# CVE-2022-24765 exception
git_safe_dir <- system(
sprintf("git config --global --add safe.directory '%s'", getwd())
)
cat(paste0("INPUT_REPORT_PKG_DIR = ", Sys.getenv("INPUT_REPORT_PKG_DIR", ".")))
# Get the action inputs from preset env vars
pkg_dir <- normalizePath(Sys.getenv("INPUT_REPORT_PKG_DIR", "."))
template_path <- Sys.getenv("INPUT_REPORT_TEMPLATE_PATH", "./template.qmd")
disable_install_dev_deps <- tolower(
Sys.getenv("DISABLE_INSTALL_DEV_DEPS")
) %in% c("yes", "y", "t", "true")
# fail with meaningful message if REPORT_PKG_DIR does not appear to be a package
desc_file <- file.path(pkg_dir, "DESCRIPTION")
if (!file.exists(desc_file)) {
stop(sprintf(
paste(sep = "\n",
"Could not find package at '%s'",
" ",
" Specify a directory by definining environment variable:",
" INPUT_REPORT_PKG_DIR=<repository subdirectory>",
" "
),
pkg_dir
))
}
# Install package dependencies
if (!disable_install_dev_deps) {
options("remotes.git_credentials" = git2r::cred_user_pass(
username = "token",
password = remotes:::github_pat()
))
devtools::install_dev_deps(pkg_dir, upgrade = "never")
}
library(quarto)
cat(paste0("Running Quarto render for template: ", template_path))
quarto_render(template_path, output_file = "validation_report.pdf")