Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHA workflow for site deploy to Connect #1543

Merged
merged 13 commits into from
Jan 26, 2024
67 changes: 67 additions & 0 deletions .github/workflows/connect-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
on:
push:
branches:
- master
pull_request:
branches:
- master

name: quarto-connect-gt-examples-site

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: pre-release

- name: Print Quarto version
run: |
quarto --version

- uses: r-lib/actions/setup-r@v2
with:
r-version: '4.2'
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
gt
shiny
tidyverse
dplyr
tidyr
ggplot2
lubridate
paletteer
janitor
rsconnect
any::sessioninfo
dependencies: '"hard"'

- name: Install package
run: R CMD INSTALL .

- name: Generate Quarto files for the website
run: |
Rscript -e 'gt:::write_gt_examples_qmd_files()'

- name: Build Quarto site
run: |
quarto render gt_qmd_examples

- name: Publish to Connect
uses: quarto-dev/quarto-actions/publish@v2
with:
target: connect
path: gt_qmd_examples
render: false
CONNECT_SERVER: ${{ secrets.CONNECT_SERVER }}
CONNECT_API_KEY: ${{ secrets.CONNECT_API_KEY }}
39 changes: 33 additions & 6 deletions R/utils_examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ write_gt_examples_qmd_files <- function(
index_tbl <- dplyr::bind_rows(index_tbl, index_tbl_i)
}

index_tbl <-
index_tbl_gt <-
index_tbl %>%
dplyr::arrange(family, number) %>%
dplyr::mutate(
name = dplyr::case_when(
type == "function" ~ paste0(
"[`", name, "()`](gt-", name , ".qmd)"
"[", name, "()](gt-", name , ".qmd)"
),
.default = name
)
Expand All @@ -299,17 +299,31 @@ write_gt_examples_qmd_files <- function(
) %>%
gt(groupname_col = "group", process_md = TRUE) %>%
fmt_markdown() %>%
fmt_url(columns = name, color = "#045AA2", target = "_self") %>%
cols_hide(columns = c(type, family, number)) %>%
tab_style(
style = cell_text(
font = system_fonts("monospace-code"),
weight = 500
),
locations = cells_body(columns = name)
) %>%
tab_options(column_labels.hidden = TRUE)

writeLines(
text = c(
"---",
"format: html",
"html-table-processing: none",
"---",
"",
paste("The **gt** package has", nrow(index_tbl), "functions."),
"Each of these functions has documentation filled with examples.",
"The table below organizes all of the functions into families and ",
"links to separate pages of **gt** table examples by function.",
"",
"```{=html}",
as_raw_html(index_tbl),
as_raw_html(index_tbl_gt),
"```",
""
),
Expand All @@ -320,14 +334,16 @@ write_gt_examples_qmd_files <- function(
text = c(
"project:",
" type: website",
"",
"render:",
" - \"*.qmd\"",
"",
"website:",
" title: \"The gt package\"",
"navbar:",
" left:",
" - href: index.qmd",
" navbar:",
" left:",
" - text: \"home\"",
" file: index.qmd",
"",
"format:",
" html:",
Expand All @@ -344,6 +360,7 @@ write_gt_examples_qmd_files <- function(
text = c(
"---",
"format: html",
"html-table-processing: none",
"toc: false",
"---",
"",
Expand All @@ -358,6 +375,16 @@ write_gt_examples_qmd_files <- function(
con = paste0(output_dir, "/gt-", topic, ".qmd")
)
}

writeLines(
text = c(
"- source: project",
" connect:",
" - id: b5709bdb-5712-42db-b265-2bfa02b5ffb6"#,
#" - url: https://colorado.posit.co/rsc/content/b5709bdb-5712-42db-b265-2bfa02b5ffb6/"
),
con = paste0(output_dir, "/_publish.yml")
)
}

#nocov end
Loading