From cab68aa69af03e0aa3ac4d341eee601dc218cf05 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Tue, 14 Dec 2021 11:38:43 -0500 Subject: [PATCH 01/13] Add document workflow --- examples/document.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/document.yaml diff --git a/examples/document.yaml b/examples/document.yaml new file mode 100644 index 000000000..29bf33dac --- /dev/null +++ b/examples/document.yaml @@ -0,0 +1,42 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ["R/**"] + pull_request: + paths: ["R/**"] + +name: Document + +jobs: + document: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: Commit and push changes + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m "Update documentation" || echo "No changes to commit" + git push origin || echo "No changes to commit" From a54b81c2cdad7480803b90f1fe7a92a05d6eb64a Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Tue, 14 Dec 2021 15:12:39 -0500 Subject: [PATCH 02/13] Add style workflow --- examples/style.yaml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 examples/style.yaml diff --git a/examples/style.yaml b/examples/style.yaml new file mode 100644 index 000000000..63a200a49 --- /dev/null +++ b/examples/style.yaml @@ -0,0 +1,43 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ["R/**"] + pull_request: + paths: ["R/**"] + +name: Style + +jobs: + style: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::styler + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: Commit and push changes + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add R/\* + git commit -m "Style code" || echo "No changes to commit" + git pull --ff-only || echo "No remote changes" + git push origin || echo "No changes to commit" From a5d5ede0985eddb7cc16f76b4ae2dd518c95aad6 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Tue, 14 Dec 2021 15:12:56 -0500 Subject: [PATCH 03/13] Pull before push --- examples/document.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/document.yaml b/examples/document.yaml index 29bf33dac..eb5a02c55 100644 --- a/examples/document.yaml +++ b/examples/document.yaml @@ -39,4 +39,5 @@ jobs: git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add man/\* NAMESPACE git commit -m "Update documentation" || echo "No changes to commit" + git pull --ff-only || echo "No remote changes" git push origin || echo "No changes to commit" From 7d0d6e5ff8c2ebb77298c92ffbee22ac34ab95c2 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Tue, 14 Dec 2021 15:13:17 -0500 Subject: [PATCH 04/13] Add new workflows to README --- examples/README.Rmd | 24 ++++++++++ examples/README.md | 111 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/examples/README.Rmd b/examples/README.Rmd index 61616b57e..64eba9f53 100644 --- a/examples/README.Rmd +++ b/examples/README.Rmd @@ -21,6 +21,8 @@ Package workflows: - [`lint`](#lint-workflow) - Run `lintr::lint_package()` on an R package. - [`pr-commands`](#commands-workflow) - Adds `/document` and `/style` commands for pull requests. - [`pkgdown`](#build-pkgdown-site) - Build a [pkgdown] site for an R package and deploy it to [GitHub Pages]. +- [`document`](#document-package) - Run `roxygen2::roxygenise()` on an R package. +- [`style`](#style-package) - Run `styler::style_pkg()` on an R package. RMarkdown workflows: @@ -164,6 +166,28 @@ The inclusion of [`workflow_dispatch`](https://docs.github.com/en/actions/learn- print_yaml("pkgdown.yaml") ``` +## Document package + +`usethis::use_github_action("document")` + +This example documents an R package whenever a file in the `R/` directory changes, then commits and pushes the changes +to the same branch. + +```{r echo = FALSE, results = "asis"} +print_yaml("document.yaml") +``` + +## Style package + +`usethis::use_github_action("document")` + +This example styles the R code in a package, then commits and pushes the changes +to the same branch. + +```{r echo = FALSE, results = "asis"} +print_yaml("style.yaml") +``` + ## Build bookdown site `usethis::use_github_action("bookdown")` diff --git a/examples/README.md b/examples/README.md index dd0a1ed0d..2084e7df0 100644 --- a/examples/README.md +++ b/examples/README.md @@ -19,6 +19,10 @@ Package workflows: - [`pkgdown`](#build-pkgdown-site) - Build a [pkgdown](https://pkgdown.r-lib.org/) site for an R package and deploy it to [GitHub Pages](https://pages.github.com/). +- [`document`](#document-package) - Run `roxygen2::roxygenise()` on an + R package. +- [`style`](#style-package) - Run `styler::style_pkg()` on an R + package. RMarkdown workflows: @@ -525,6 +529,113 @@ jobs: Rscript -e 'pkgdown::build_site(preview = FALSE, install = FALSE)' ``` +## Document package + +`usethis::use_github_action("document")` + +This example documents an R package whenever a file in the `R/` +directory changes, then commits and pushes the changes to the same +branch. + +``` yaml +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ["R/**"] + pull_request: + paths: ["R/**"] + +name: Document + +jobs: + document: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: Commit and push changes + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m "Update documentation" || echo "No changes to commit" + git pull --ff-only || echo "No remote changes" + git push origin || echo "No changes to commit" +``` + +## Style package + +`usethis::use_github_action("document")` + +This example styles the R code in a package, then commits and pushes the +changes to the same branch. + +``` yaml +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ["R/**"] + pull_request: + paths: ["R/**"] + +name: Style + +jobs: + style: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::styler + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: Commit and push changes + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add R/\* + git commit -m "Style code" || echo "No changes to commit" + git pull --ff-only || echo "No remote changes" + git push origin || echo "No changes to commit" +``` + ## Build bookdown site `usethis::use_github_action("bookdown")` From 9a30bc92edcea1246af10f6c6a748e952e405f62 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Tue, 14 Dec 2021 15:15:40 -0500 Subject: [PATCH 05/13] Fix section ordering Section ordering now properly reflects the bullets in the beginning of the README --- examples/README.Rmd | 52 +++++------ examples/README.md | 216 ++++++++++++++++++++++---------------------- 2 files changed, 134 insertions(+), 134 deletions(-) diff --git a/examples/README.Rmd b/examples/README.Rmd index 64eba9f53..c6f3ef233 100644 --- a/examples/README.Rmd +++ b/examples/README.Rmd @@ -144,16 +144,6 @@ package. print_yaml("pr-commands.yaml") ``` -## Render Rmarkdown - -`usethis::use_github_action("render-rmarkdown")` - -This example automatically re-builds any Rmarkdown file in the repository whenever it changes and commits the results to the same branch. - -```{r echo = FALSE, results = "asis"} -print_yaml("render-rmarkdown.yaml") -``` - ## Build pkgdown site `usethis::use_github_action("pkgdown")` @@ -188,6 +178,16 @@ to the same branch. print_yaml("style.yaml") ``` +## Render Rmarkdown + +`usethis::use_github_action("render-rmarkdown")` + +This example automatically re-builds any Rmarkdown file in the repository whenever it changes and commits the results to the same branch. + +```{r echo = FALSE, results = "asis"} +print_yaml("render-rmarkdown.yaml") +``` + ## Build bookdown site `usethis::use_github_action("bookdown")` @@ -214,22 +214,6 @@ You will need to run `renv::snapshot()` locally and commit the `renv.lock` file print_yaml("blogdown.yaml") ``` -## Shiny App Deployment - -`usethis::use_github_action("shiny-deploy")` - -This example will deploy your Shiny application to either [shinyapps.io](https://www.shinyapps.io/) or [RStudio Connect](https://www.rstudio.com/products/connect/) using the `rsconnect` package. The `rsconnect` package requires authorization to deploy an app using your account. This action does this by using your user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret (`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. **Your token and secret are private and should be kept confidential**. - -This action assumes you have an `renv` lockfile in your repository that describes the `R` packages and versions required for your Shiny application. - -- See here for information on how to obtain the token and secret for configuring `rsconnect`: https://shiny.rstudio.com/articles/shinyapps.html - -- See here for information on how to store private tokens in a repository as GitHub Secrets: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository - -```{r echo = FALSE, results = "asis"} -print_yaml("shiny-deploy.yaml") -``` - ## Docker based workflow `usethis::use_github_action("docker")` @@ -281,6 +265,22 @@ This example uses the [lintr](https://github.com/jimhester/lintr) package to lin print_yaml("lint-project.yaml") ``` +## Shiny App Deployment + +`usethis::use_github_action("shiny-deploy")` + +This example will deploy your Shiny application to either [shinyapps.io](https://www.shinyapps.io/) or [RStudio Connect](https://www.rstudio.com/products/connect/) using the `rsconnect` package. The `rsconnect` package requires authorization to deploy an app using your account. This action does this by using your user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret (`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. **Your token and secret are private and should be kept confidential**. + +This action assumes you have an `renv` lockfile in your repository that describes the `R` packages and versions required for your Shiny application. + +- See here for information on how to obtain the token and secret for configuring `rsconnect`: https://shiny.rstudio.com/articles/shinyapps.html + +- See here for information on how to store private tokens in a repository as GitHub Secrets: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository + +```{r echo = FALSE, results = "asis"} +print_yaml("shiny-deploy.yaml") +``` + ## Forcing binaries diff --git a/examples/README.md b/examples/README.md index 2084e7df0..d58876d4a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -423,53 +423,6 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} ``` -## Render Rmarkdown - -`usethis::use_github_action("render-rmarkdown")` - -This example automatically re-builds any Rmarkdown file in the -repository whenever it changes and commits the results to the same -branch. - -``` yaml -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - paths: ['**.Rmd'] - -name: render-rmarkdown - -jobs: - render-rmarkdown: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Checkout repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - - - uses: r-lib/actions/setup-renv@v2 - - - name: Render Rmarkdown files - run: | - RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$')) - Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]} - - - name: Commit results - run: | - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit" - git push origin || echo "No changes to commit" -``` - ## Build pkgdown site `usethis::use_github_action("pkgdown")` @@ -636,6 +589,53 @@ jobs: git push origin || echo "No changes to commit" ``` +## Render Rmarkdown + +`usethis::use_github_action("render-rmarkdown")` + +This example automatically re-builds any Rmarkdown file in the +repository whenever it changes and commits the results to the same +branch. + +``` yaml +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ['**.Rmd'] + +name: render-rmarkdown + +jobs: + render-rmarkdown: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + + - uses: r-lib/actions/setup-renv@v2 + + - name: Render Rmarkdown files + run: | + RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$')) + Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]} + + - name: Commit results + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit" + git push origin || echo "No changes to commit" +``` + ## Build bookdown site `usethis::use_github_action("bookdown")` @@ -759,67 +759,6 @@ jobs: folder: public ``` -## Shiny App Deployment - -`usethis::use_github_action("shiny-deploy")` - -This example will deploy your Shiny application to either -[shinyapps.io](https://www.shinyapps.io/) or [RStudio -Connect](https://www.rstudio.com/products/connect/) using the -`rsconnect` package. The `rsconnect` package requires authorization to -deploy an app using your account. This action does this by using your -user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret -(`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. -**Your token and secret are private and should be kept confidential**. - -This action assumes you have an `renv` lockfile in your repository that -describes the `R` packages and versions required for your Shiny -application. - -- See here for information on how to obtain the token and secret for - configuring `rsconnect`: - - -- See here for information on how to store private tokens in a - repository as GitHub Secrets: - - -``` yaml -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - branches: [main, master] - -name: shiny-deploy - -jobs: - shiny-deploy: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-renv@v2 - - - name: Install rsconnect - run: install.packages("rsconnect") - shell: Rscript {0} - - - name: Authorize and deploy app - run: | - rsconnect::setAccountInfo(${{ secrets.RSCONNECT_USER }}, ${{ secrets.RSCONNECT_TOKEN }}, ${{ secrets.RSCONNECT_SECRET }}) - rsconnect::deployApp() - shell: Rscript {0} -``` - ## Docker based workflow `usethis::use_github_action("docker")` @@ -921,6 +860,67 @@ jobs: shell: Rscript {0} ``` +## Shiny App Deployment + +`usethis::use_github_action("shiny-deploy")` + +This example will deploy your Shiny application to either +[shinyapps.io](https://www.shinyapps.io/) or [RStudio +Connect](https://www.rstudio.com/products/connect/) using the +`rsconnect` package. The `rsconnect` package requires authorization to +deploy an app using your account. This action does this by using your +user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret +(`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. +**Your token and secret are private and should be kept confidential**. + +This action assumes you have an `renv` lockfile in your repository that +describes the `R` packages and versions required for your Shiny +application. + +- See here for information on how to obtain the token and secret for + configuring `rsconnect`: + + +- See here for information on how to store private tokens in a + repository as GitHub Secrets: + + +``` yaml +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + +name: shiny-deploy + +jobs: + shiny-deploy: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-renv@v2 + + - name: Install rsconnect + run: install.packages("rsconnect") + shell: Rscript {0} + + - name: Authorize and deploy app + run: | + rsconnect::setAccountInfo(${{ secrets.RSCONNECT_USER }}, ${{ secrets.RSCONNECT_TOKEN }}, ${{ secrets.RSCONNECT_SECRET }}) + rsconnect::deployApp() + shell: Rscript {0} +``` + ## Forcing binaries Code repositories such as [CRAN](http://cran.r-project.org) or From 69a7a3d4d9929a8ce4a0f5d1a2e256ee648d0115 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Tue, 14 Dec 2021 15:15:40 -0500 Subject: [PATCH 06/13] Revert "Fix section ordering" This reverts commit 9a30bc92edcea1246af10f6c6a748e952e405f62. --- examples/README.Rmd | 52 +++++------ examples/README.md | 216 ++++++++++++++++++++++---------------------- 2 files changed, 134 insertions(+), 134 deletions(-) diff --git a/examples/README.Rmd b/examples/README.Rmd index c6f3ef233..64eba9f53 100644 --- a/examples/README.Rmd +++ b/examples/README.Rmd @@ -144,6 +144,16 @@ package. print_yaml("pr-commands.yaml") ``` +## Render Rmarkdown + +`usethis::use_github_action("render-rmarkdown")` + +This example automatically re-builds any Rmarkdown file in the repository whenever it changes and commits the results to the same branch. + +```{r echo = FALSE, results = "asis"} +print_yaml("render-rmarkdown.yaml") +``` + ## Build pkgdown site `usethis::use_github_action("pkgdown")` @@ -178,16 +188,6 @@ to the same branch. print_yaml("style.yaml") ``` -## Render Rmarkdown - -`usethis::use_github_action("render-rmarkdown")` - -This example automatically re-builds any Rmarkdown file in the repository whenever it changes and commits the results to the same branch. - -```{r echo = FALSE, results = "asis"} -print_yaml("render-rmarkdown.yaml") -``` - ## Build bookdown site `usethis::use_github_action("bookdown")` @@ -214,6 +214,22 @@ You will need to run `renv::snapshot()` locally and commit the `renv.lock` file print_yaml("blogdown.yaml") ``` +## Shiny App Deployment + +`usethis::use_github_action("shiny-deploy")` + +This example will deploy your Shiny application to either [shinyapps.io](https://www.shinyapps.io/) or [RStudio Connect](https://www.rstudio.com/products/connect/) using the `rsconnect` package. The `rsconnect` package requires authorization to deploy an app using your account. This action does this by using your user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret (`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. **Your token and secret are private and should be kept confidential**. + +This action assumes you have an `renv` lockfile in your repository that describes the `R` packages and versions required for your Shiny application. + +- See here for information on how to obtain the token and secret for configuring `rsconnect`: https://shiny.rstudio.com/articles/shinyapps.html + +- See here for information on how to store private tokens in a repository as GitHub Secrets: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository + +```{r echo = FALSE, results = "asis"} +print_yaml("shiny-deploy.yaml") +``` + ## Docker based workflow `usethis::use_github_action("docker")` @@ -265,22 +281,6 @@ This example uses the [lintr](https://github.com/jimhester/lintr) package to lin print_yaml("lint-project.yaml") ``` -## Shiny App Deployment - -`usethis::use_github_action("shiny-deploy")` - -This example will deploy your Shiny application to either [shinyapps.io](https://www.shinyapps.io/) or [RStudio Connect](https://www.rstudio.com/products/connect/) using the `rsconnect` package. The `rsconnect` package requires authorization to deploy an app using your account. This action does this by using your user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret (`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. **Your token and secret are private and should be kept confidential**. - -This action assumes you have an `renv` lockfile in your repository that describes the `R` packages and versions required for your Shiny application. - -- See here for information on how to obtain the token and secret for configuring `rsconnect`: https://shiny.rstudio.com/articles/shinyapps.html - -- See here for information on how to store private tokens in a repository as GitHub Secrets: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository - -```{r echo = FALSE, results = "asis"} -print_yaml("shiny-deploy.yaml") -``` - ## Forcing binaries diff --git a/examples/README.md b/examples/README.md index d58876d4a..2084e7df0 100644 --- a/examples/README.md +++ b/examples/README.md @@ -423,6 +423,53 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} ``` +## Render Rmarkdown + +`usethis::use_github_action("render-rmarkdown")` + +This example automatically re-builds any Rmarkdown file in the +repository whenever it changes and commits the results to the same +branch. + +``` yaml +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ['**.Rmd'] + +name: render-rmarkdown + +jobs: + render-rmarkdown: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + + - uses: r-lib/actions/setup-renv@v2 + + - name: Render Rmarkdown files + run: | + RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$')) + Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]} + + - name: Commit results + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit" + git push origin || echo "No changes to commit" +``` + ## Build pkgdown site `usethis::use_github_action("pkgdown")` @@ -589,53 +636,6 @@ jobs: git push origin || echo "No changes to commit" ``` -## Render Rmarkdown - -`usethis::use_github_action("render-rmarkdown")` - -This example automatically re-builds any Rmarkdown file in the -repository whenever it changes and commits the results to the same -branch. - -``` yaml -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - paths: ['**.Rmd'] - -name: render-rmarkdown - -jobs: - render-rmarkdown: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - name: Checkout repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - - - uses: r-lib/actions/setup-renv@v2 - - - name: Render Rmarkdown files - run: | - RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$')) - Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]} - - - name: Commit results - run: | - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit" - git push origin || echo "No changes to commit" -``` - ## Build bookdown site `usethis::use_github_action("bookdown")` @@ -759,6 +759,67 @@ jobs: folder: public ``` +## Shiny App Deployment + +`usethis::use_github_action("shiny-deploy")` + +This example will deploy your Shiny application to either +[shinyapps.io](https://www.shinyapps.io/) or [RStudio +Connect](https://www.rstudio.com/products/connect/) using the +`rsconnect` package. The `rsconnect` package requires authorization to +deploy an app using your account. This action does this by using your +user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret +(`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. +**Your token and secret are private and should be kept confidential**. + +This action assumes you have an `renv` lockfile in your repository that +describes the `R` packages and versions required for your Shiny +application. + +- See here for information on how to obtain the token and secret for + configuring `rsconnect`: + + +- See here for information on how to store private tokens in a + repository as GitHub Secrets: + + +``` yaml +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + +name: shiny-deploy + +jobs: + shiny-deploy: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-renv@v2 + + - name: Install rsconnect + run: install.packages("rsconnect") + shell: Rscript {0} + + - name: Authorize and deploy app + run: | + rsconnect::setAccountInfo(${{ secrets.RSCONNECT_USER }}, ${{ secrets.RSCONNECT_TOKEN }}, ${{ secrets.RSCONNECT_SECRET }}) + rsconnect::deployApp() + shell: Rscript {0} +``` + ## Docker based workflow `usethis::use_github_action("docker")` @@ -860,67 +921,6 @@ jobs: shell: Rscript {0} ``` -## Shiny App Deployment - -`usethis::use_github_action("shiny-deploy")` - -This example will deploy your Shiny application to either -[shinyapps.io](https://www.shinyapps.io/) or [RStudio -Connect](https://www.rstudio.com/products/connect/) using the -`rsconnect` package. The `rsconnect` package requires authorization to -deploy an app using your account. This action does this by using your -user name (`RSCONNECT_USER`), token (`RSCONNECT_TOKEN`), and secret -(`RSCONNECT_SECRET`), which are securely accessed as GitHub Secrets. -**Your token and secret are private and should be kept confidential**. - -This action assumes you have an `renv` lockfile in your repository that -describes the `R` packages and versions required for your Shiny -application. - -- See here for information on how to obtain the token and secret for - configuring `rsconnect`: - - -- See here for information on how to store private tokens in a - repository as GitHub Secrets: - - -``` yaml -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - branches: [main, master] - -name: shiny-deploy - -jobs: - shiny-deploy: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-renv@v2 - - - name: Install rsconnect - run: install.packages("rsconnect") - shell: Rscript {0} - - - name: Authorize and deploy app - run: | - rsconnect::setAccountInfo(${{ secrets.RSCONNECT_USER }}, ${{ secrets.RSCONNECT_TOKEN }}, ${{ secrets.RSCONNECT_SECRET }}) - rsconnect::deployApp() - shell: Rscript {0} -``` - ## Forcing binaries Code repositories such as [CRAN](http://cran.r-project.org) or From 5abf4b21c4fda631138a886456602e7c1dabc590 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Wed, 15 Dec 2021 15:39:18 -0500 Subject: [PATCH 07/13] Add needs field to r dependencies action --- examples/document.yaml | 1 + examples/style.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/document.yaml b/examples/document.yaml index eb5a02c55..68b42e004 100644 --- a/examples/document.yaml +++ b/examples/document.yaml @@ -28,6 +28,7 @@ jobs: uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: any::roxygen2 + needs: roxygen2 - name: Document run: roxygen2::roxygenise() diff --git a/examples/style.yaml b/examples/style.yaml index 63a200a49..b488d79d8 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -28,6 +28,7 @@ jobs: uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: any::styler + needs: styler - name: Style run: styler::style_pkg() From 056dc91da0df723f75309bd4ddc6c1849d7e04b5 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Wed, 15 Dec 2021 16:41:50 -0500 Subject: [PATCH 08/13] Let `pull` and `push` fail --- examples/document.yaml | 4 ++-- examples/style.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/document.yaml b/examples/document.yaml index 68b42e004..9a772c085 100644 --- a/examples/document.yaml +++ b/examples/document.yaml @@ -40,5 +40,5 @@ jobs: git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add man/\* NAMESPACE git commit -m "Update documentation" || echo "No changes to commit" - git pull --ff-only || echo "No remote changes" - git push origin || echo "No changes to commit" + git pull --ff-only + git push origin diff --git a/examples/style.yaml b/examples/style.yaml index b488d79d8..1f5318e25 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -40,5 +40,5 @@ jobs: git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add R/\* git commit -m "Style code" || echo "No changes to commit" - git pull --ff-only || echo "No remote changes" - git push origin || echo "No changes to commit" + git pull --ff-only + git push origin From 4e2199a1ba1746335501141f3b843e40c228fdbc Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Mon, 20 Dec 2021 12:29:06 -0500 Subject: [PATCH 09/13] Cache styler --- examples/style.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/style.yaml b/examples/style.yaml index 1f5318e25..d0d068dbe 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -30,6 +30,27 @@ jobs: extra-packages: any::styler needs: styler + - name: Enable styler cache + run: styler::cache_activate() + shell: Rscript {0} + + - name: Determine cache location + id: styler-loc + run: | + cat( + "##[set-output name=loc;]", + styler::cache_info(format = "tabular")$location, + "\n", + sep = "" + ) + shell: Rscript {0} + + - name: Cache styler + uses: actions/cache@v2 + with: + path: ${{ steps.styler-loc.outputs.loc }} + key: ${{ runner.os }}-styler + - name: Style run: styler::style_pkg() shell: Rscript {0} From 7277313d9a11961a9484d1979089c4af681b5451 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Sun, 16 Jan 2022 15:32:29 -0500 Subject: [PATCH 10/13] Add github SHA to cache key and add restore-keys --- examples/style.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/style.yaml b/examples/style.yaml index d0d068dbe..f5bca026f 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -49,7 +49,10 @@ jobs: uses: actions/cache@v2 with: path: ${{ steps.styler-loc.outputs.loc }} - key: ${{ runner.os }}-styler + key: ${{ runner.os }}-styler-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-styler- + ${{ runner.os }}- - name: Style run: styler::style_pkg() From 3a2e1dad31e18df40379f39b50c16bbfa79838b9 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Sun, 16 Jan 2022 15:33:11 -0500 Subject: [PATCH 11/13] Expand loc to location --- examples/style.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/style.yaml b/examples/style.yaml index f5bca026f..985ee5a64 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -35,10 +35,10 @@ jobs: shell: Rscript {0} - name: Determine cache location - id: styler-loc + id: styler-location run: | cat( - "##[set-output name=loc;]", + "##[set-output name=location;]", styler::cache_info(format = "tabular")$location, "\n", sep = "" @@ -48,7 +48,7 @@ jobs: - name: Cache styler uses: actions/cache@v2 with: - path: ${{ steps.styler-loc.outputs.loc }} + path: ${{ steps.styler-location.outputs.location }} key: ${{ runner.os }}-styler-${{ github.sha }} restore-keys: | ${{ runner.os }}-styler- From 87a5abc3edbf559c3c8fcef8ab6644043aee24f3 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Sun, 16 Jan 2022 16:31:14 -0500 Subject: [PATCH 12/13] Broaden action triggers and style more file extensions --- examples/style.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/style.yaml b/examples/style.yaml index 985ee5a64..3581ad5c6 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -2,9 +2,9 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - paths: ["R/**"] + paths: ["R/**", "tests/**", "vignettes/**"] pull_request: - paths: ["R/**"] + paths: ["R/**", "tests/**", "vignettes/**"] name: Style @@ -55,7 +55,7 @@ jobs: ${{ runner.os }}- - name: Style - run: styler::style_pkg() + run: styler::style_pkg(filetype = c(".R", ".Rmd", ".Rmarkdown", ".Rnw")) shell: Rscript {0} - name: Commit and push changes From d0ab4d087b5b1ac32626fb8b7e3af891b90ebe41 Mon Sep 17 00:00:00 2001 From: Aris Paschalidis Date: Tue, 18 Jan 2022 22:15:28 -0500 Subject: [PATCH 13/13] Set paths as file extensions rather than directories --- examples/style.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/style.yaml b/examples/style.yaml index 3581ad5c6..f0bb30cba 100644 --- a/examples/style.yaml +++ b/examples/style.yaml @@ -2,9 +2,9 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - paths: ["R/**", "tests/**", "vignettes/**"] + paths: ["**.[rR]", "**.[rR]md", "**.[rR]markdown", "**.[rR]nw"] pull_request: - paths: ["R/**", "tests/**", "vignettes/**"] + paths: ["**.[rR]", "**.[rR]md", "**.[rR]markdown", "**.[rR]nw"] name: Style