From bc8320839a8d0af1e88cadfa533048e49eeee845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 8 May 2024 19:33:33 +0200 Subject: [PATCH] Example workflows for bookdown / blogdown w/o git (#856) Closes #623 --- examples/README.Rmd | 23 +++++ examples/README.md | 156 ++++++++++++++++++++++++++++++++ examples/blogdown-gh-pages.yaml | 62 +++++++++++++ examples/bookdown-gh-pages.yaml | 65 +++++++++++++ 4 files changed, 306 insertions(+) create mode 100644 examples/blogdown-gh-pages.yaml create mode 100644 examples/bookdown-gh-pages.yaml diff --git a/examples/README.Rmd b/examples/README.Rmd index e132010f6..4c681badd 100644 --- a/examples/README.Rmd +++ b/examples/README.Rmd @@ -28,7 +28,9 @@ RMarkdown workflows: - [`render-rmarkdown`](#render-rmarkdown) - Render one or more Rmarkdown files when they change and commit the result. - [`bookdown`](#build-bookdown-site) - Build a [bookdown] site and deploy it to [GitHub Pages] or [Cloudflare Pages]. +- [`bookdown-gh-pages`](#build-bookdown-site-alternative-workflow) - Alternative workflow to build a [bookdown] site and deploy it to [GitHub Pages]. - [`blogdown`](#build-blogdown-site) - Build a [blogdown] site and deploy it to [GitHub Pages] or [Cloudflare Pages]. +- [`blogdown-gh-pages`](#build-blogdown-site-alternative-workflow) - Alternative workflow to build a [blogdown] site and deploy it to [GitHub Pages]. Other workflows: @@ -225,6 +227,17 @@ Pages documentation for details. print_yaml("bookdown.yaml") ``` +## Build bookdown site, alternative workflow + +`usethis::use_github_action("bookdown-gh-pages")` + +This is an alternative workflow that builds and publishes a bookdown book, +without creating a separate branch in the repository for the built book. + +```{r echo = FALSE, results = "asis"} +print_yaml("bookdown-gh-pages.yaml") +``` + ## Build blogdown site `usethis::use_github_action("blogdown")` @@ -245,6 +258,16 @@ Pages documentation for details. ```{r echo = FALSE, results = "asis"} print_yaml("blogdown.yaml") ``` +## Build blogdown site, alternative workflow + +`usethis::use_github_action("blogdown-gh-pages")` + +This is an alternative workflow that builds and publishes a blogdown site, +without creating a separate branch in the repository for the built site. + +```{r echo = FALSE, results = "asis"} +print_yaml("blogdown-gh-pages.yaml") +``` ## Shiny App Deployment diff --git a/examples/README.md b/examples/README.md index fbc2657e9..ecc9f54ed 100644 --- a/examples/README.md +++ b/examples/README.md @@ -32,10 +32,17 @@ RMarkdown workflows: [bookdown](https://bookdown.org) site and deploy it to [GitHub Pages](https://pages.github.com/) or [Cloudflare Pages](https://pages.cloudflare.com/). +- [`bookdown-gh-pages`](#build-bookdown-site-alternative-workflow) - + Alternative workflow to build a [bookdown](https://bookdown.org) site + and deploy it to [GitHub Pages](https://pages.github.com/). - [`blogdown`](#build-blogdown-site) - Build a [blogdown](https://bookdown.org/yihui/blogdown/) site and deploy it to [GitHub Pages](https://pages.github.com/) or [Cloudflare Pages](https://pages.cloudflare.com/). +- [`blogdown-gh-pages`](#build-blogdown-site-alternative-workflow) - + Alternative workflow to build a + [blogdown](https://bookdown.org/yihui/blogdown/) site and deploy it to + [GitHub Pages](https://pages.github.com/). Other workflows: @@ -812,6 +819,82 @@ jobs: folder: _book ``` +## Build bookdown site, alternative workflow + +`usethis::use_github_action("bookdown-gh-pages")` + +This is an alternative workflow that builds and publishes a bookdown +book, without creating a separate branch in the repository for the built +book. + +``` 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] + pull_request: + branches: [main, master] + workflow_dispatch: + +name: Deploy bookdown to GH Pages + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - 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: Cache bookdown results + uses: actions/cache@v4 + with: + path: _bookdown_files + key: bookdown-${{ hashFiles('**/*Rmd') }} + restore-keys: bookdown- + + - name: Build site + run: bookdown::render_book("index.Rmd", quiet = TRUE) + shell: Rscript {0} + + - name: Upload website artifact + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} + uses: actions/upload-pages-artifact@v3 + with: + path: "_book" + + deploy: + needs: build + + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 +``` + ## Build blogdown site `usethis::use_github_action("blogdown")` @@ -882,6 +965,79 @@ jobs: folder: public ``` +## Build blogdown site, alternative workflow + +`usethis::use_github_action("blogdown-gh-pages")` + +This is an alternative workflow that builds and publishes a blogdown +site, without creating a separate branch in the repository for the built +site. + +``` 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] + pull_request: + branches: [main, master] + workflow_dispatch: + +name: Deploy blogdown to GH Pages + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - 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 hugo + run: blogdown::install_hugo() + shell: Rscript {0} + + - name: Build site + run: blogdown::build_site(TRUE) + shell: Rscript {0} + + - name: Upload website artifact + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} + uses: actions/upload-pages-artifact@v3 + with: + path: "public" + + deploy: + needs: build + + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 +``` + ## Shiny App Deployment `usethis::use_github_action("shiny-deploy")` diff --git a/examples/blogdown-gh-pages.yaml b/examples/blogdown-gh-pages.yaml new file mode 100644 index 000000000..e44e9876c --- /dev/null +++ b/examples/blogdown-gh-pages.yaml @@ -0,0 +1,62 @@ +# 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] + pull_request: + branches: [main, master] + workflow_dispatch: + +name: Deploy blogdown to GH Pages + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - 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 hugo + run: blogdown::install_hugo() + shell: Rscript {0} + + - name: Build site + run: blogdown::build_site(TRUE) + shell: Rscript {0} + + - name: Upload website artifact + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} + uses: actions/upload-pages-artifact@v3 + with: + path: "public" + + deploy: + needs: build + + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/examples/bookdown-gh-pages.yaml b/examples/bookdown-gh-pages.yaml new file mode 100644 index 000000000..7cafe0044 --- /dev/null +++ b/examples/bookdown-gh-pages.yaml @@ -0,0 +1,65 @@ +# 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] + pull_request: + branches: [main, master] + workflow_dispatch: + +name: Deploy bookdown to GH Pages + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - 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: Cache bookdown results + uses: actions/cache@v4 + with: + path: _bookdown_files + key: bookdown-${{ hashFiles('**/*Rmd') }} + restore-keys: bookdown- + + - name: Build site + run: bookdown::render_book("index.Rmd", quiet = TRUE) + shell: Rscript {0} + + - name: Upload website artifact + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }} + uses: actions/upload-pages-artifact@v3 + with: + path: "_book" + + deploy: + needs: build + + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4