Skip to content

Commit

Permalink
Add automation to remove non-distill site (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored Oct 16, 2023
1 parent 989d0f9 commit 5034b8f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
26 changes: 26 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions vignettes/examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 5034b8f

Please sign in to comment.