diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 68721389..cfdd8df2 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -45,6 +45,32 @@ jobs: run: pkgdown::build_site(new_process = FALSE, install = FALSE) shell: Rscript {0} + - name: update examples file if non distill site detected + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + add-paths: vignettes/examples.yml + commit-message: | + Remove non-distill example website [auto PR] + branch: updates/example-gallery + delete-branch: true + assignees: cderv + reviewers: cderv + title: | + [CI] Remove non-distill example website + body: | + This PR was created automatically after rendering vignette because some example website does not seem to use distill anymore. + Please review and merge. + base: main + + - name: Check auto PR outputs + if: steps.cpr.outcome == 'success' + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + echo "Pull Request Action Performed - ${{ steps.cpr.outputs.pull-request-operation }}" + - name: Deploy to Netlify id: netlify-deploy uses: nwtgck/actions-netlify@v2 diff --git a/DESCRIPTION b/DESCRIPTION index d54085ce..fa5b63db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -66,7 +66,7 @@ Suggests: shiny, testthat (>= 3.0.0), withr -Config/Needs/website: rstudio/quillt, pkgdown, tidyverse/tidytemplate +Config/Needs/website: rstudio/quillt, pkgdown, tidyverse/tidytemplate, rvest Config/testthat/edition: 3 Encoding: UTF-8 Language: en-US diff --git a/vignettes/examples.Rmd b/vignettes/examples.Rmd index 11fec001..9ae5bd4c 100755 --- a/vignettes/examples.Rmd +++ b/vignettes/examples.Rmd @@ -8,6 +8,25 @@ resource_files: library(quillt) ``` +```{r, include = FALSE} +# check yaml examples +sites <- yaml::read_yaml("examples.yml") +is_working_distill <- vapply(sites, function(s) { + # check for error + if (httr::http_error(httr::GET(s$href))) return(FALSE) + html <- rvest::read_html(s$href) + generator <- rvest::html_attr(rvest::html_element(rvest::read_html(s$href), "meta[name='generator']"), "content") + return (is.na(generator) || generator == "distill") +}, logical(1)) +yaml::write_yaml(sites[is_working_distill], "examples.yml", handlers = list( + # Handle yes/no from 1.1 to 1.2 + # https://github.com/vubiostat/r-yaml/issues/131 + logical = function(x) { + value <- ifelse(x, "true", "false") + structure(value, class = "verbatim") + })) +``` + The examples below illustrate the use of Distill for making websites and blogs. ```{r, echo=FALSE}