From 9e141373f462e31ef2ef40c2dc2ebdb090cc7ac2 Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Wed, 7 Feb 2024 22:40:39 -0800 Subject: [PATCH 1/4] Create rwasm-binary-and-pkgdown-site.yml --- examples/rwasm-binary-and-pkgdown-site.yml | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 examples/rwasm-binary-and-pkgdown-site.yml diff --git a/examples/rwasm-binary-and-pkgdown-site.yml b/examples/rwasm-binary-and-pkgdown-site.yml new file mode 100644 index 0000000..82e00ea --- /dev/null +++ b/examples/rwasm-binary-and-pkgdown-site.yml @@ -0,0 +1,104 @@ +# Workflow derived from https://github.com/r-wasm/actions/tree/v1/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + # Only build on main or master branch + branches: [main, master] + # Or when triggered manually + workflow_dispatch: {} + +name: R WASM & {pkgdown} deploy + +jobs: + rwasmbuild: + # Only restrict concurrency for non-PR jobs + concurrency: + group: r-wasm-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Build the local R package and structure the CRAN repository + - name: Build WASM R packages + uses: r-wasm/actions/build-rwasm@v1 + with: + packages: "." + repo-path: "_site" + + # Upload the CRAN repository for use in the next step + # Make sure to set a retention day to avoid running into a cap + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: rwasmrepo + path: | + _site + retention-days: 1 + + pkgdown: + runs-on: ubuntu-latest + # Add a dependency on the prior job completing + needs: rwasmbuild + # Required for the gh-pages deployment action + environment: + name: github-pages + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + # To download GitHub Packages within action + repository-projects: read + # For publishing to pages environment + pages: write + id-token: write + steps: + # Usual steps for generating a pkgdown website + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + # Change the build directory from `docs` to `_site` + # For parity with where the R WASM package repository is setup + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, dest_dir = "_site") + shell: Rscript {0} + + # New material --- + + # Download the built R WASM CRAN repository from the prior step. + # Extract it into the `_site` directory + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: rwasmrepo + path: _site + + # Upload a tar file that will work with GitHub Pages + # Make sure to set a retention day to avoid running into a cap + # This artifact shouldn't be required after deployment onto pages was a success. + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v2 + with: + retention-days: 1 + + # Use an Action deploy to push the artifact onto GitHub Pages + # This requires the `Action` tab being structured to allow for deployment + # instead of using `docs/` or the `gh-pages` branch of the repository + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 From 243b5c6870a10e6410f62f4c9506877f88512435 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 2 Apr 2024 12:18:53 -0400 Subject: [PATCH 2/4] Apply suggestions from code review --- examples/rwasm-binary-and-pkgdown-site.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/rwasm-binary-and-pkgdown-site.yml b/examples/rwasm-binary-and-pkgdown-site.yml index 82e00ea..9e52d3d 100644 --- a/examples/rwasm-binary-and-pkgdown-site.yml +++ b/examples/rwasm-binary-and-pkgdown-site.yml @@ -5,19 +5,17 @@ on: # Only build on main or master branch branches: [main, master] # Or when triggered manually - workflow_dispatch: {} + workflow_dispatch: name: R WASM & {pkgdown} deploy jobs: rwasmbuild: - # Only restrict concurrency for non-PR jobs concurrency: - group: r-wasm-${{ github.event_name != 'pull_request' || github.run_id }} + group: r-wasm-pkgdown-build + cancel-in-progress: true env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - permissions: - contents: write runs-on: ubuntu-latest steps: - name: Checkout repository @@ -47,9 +45,9 @@ jobs: # Required for the gh-pages deployment action environment: name: github-pages - # Only restrict concurrency for non-PR jobs concurrency: - group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + group: r-wasm-pkgdown-deploy + cancel-in-progress: true env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} permissions: @@ -75,8 +73,13 @@ jobs: # Change the build directory from `docs` to `_site` # For parity with where the R WASM package repository is setup - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, dest_dir = "_site") shell: Rscript {0} + run: | + pkgdown::build_site_github_pages( + new_process = FALSE, + install = FALSE, + dest_dir = "_site" + ) # New material --- @@ -93,8 +96,6 @@ jobs: # This artifact shouldn't be required after deployment onto pages was a success. - name: Upload Pages artifact uses: actions/upload-pages-artifact@v2 - with: - retention-days: 1 # Use an Action deploy to push the artifact onto GitHub Pages # This requires the `Action` tab being structured to allow for deployment From 67b3d7354ef52545f9cc386903712fad1afd4928 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 2 Apr 2024 12:42:48 -0400 Subject: [PATCH 3/4] Make _site in first job, deploy _site in second job only on push; Add PR trigger --- examples/rwasm-binary-and-pkgdown-site.yml | 103 +++++++-------------- 1 file changed, 33 insertions(+), 70 deletions(-) diff --git a/examples/rwasm-binary-and-pkgdown-site.yml b/examples/rwasm-binary-and-pkgdown-site.yml index 9e52d3d..32aba94 100644 --- a/examples/rwasm-binary-and-pkgdown-site.yml +++ b/examples/rwasm-binary-and-pkgdown-site.yml @@ -2,76 +2,33 @@ # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - # Only build on main or master branch - branches: [main, master] - # Or when triggered manually + branches: [main] + pull_request: + branches: [main] workflow_dispatch: -name: R WASM & {pkgdown} deploy +name: R Wasm & pkgdown deploy jobs: - rwasmbuild: - concurrency: - group: r-wasm-pkgdown-build - cancel-in-progress: true + build-site: + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - runs-on: ubuntu-latest + steps: - name: Checkout repository uses: actions/checkout@v4 - - # Build the local R package and structure the CRAN repository - - name: Build WASM R packages - uses: r-wasm/actions/build-rwasm@v1 - with: - packages: "." - repo-path: "_site" - - # Upload the CRAN repository for use in the next step - # Make sure to set a retention day to avoid running into a cap - - name: Upload build artifact - uses: actions/upload-artifact@v3 - with: - name: rwasmrepo - path: | - _site - retention-days: 1 - pkgdown: - runs-on: ubuntu-latest - # Add a dependency on the prior job completing - needs: rwasmbuild - # Required for the gh-pages deployment action - environment: - name: github-pages - concurrency: - group: r-wasm-pkgdown-deploy - cancel-in-progress: true - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - permissions: - # To download GitHub Packages within action - repository-projects: read - # For publishing to pages environment - pages: write - id-token: write - steps: # Usual steps for generating a pkgdown website - - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: any::pkgdown, local::. needs: website - # Change the build directory from `docs` to `_site` - # For parity with where the R WASM package repository is setup + # Change the build directory to `_site` - name: Build site shell: Rscript {0} run: | @@ -80,26 +37,32 @@ jobs: install = FALSE, dest_dir = "_site" ) - - # New material --- - - # Download the built R WASM CRAN repository from the prior step. - # Extract it into the `_site` directory - - name: Download build artifact - uses: actions/download-artifact@v3 + + # Build the local R package and structure the CRAN repository + - name: Build Wasm R packages + uses: r-wasm/actions/build-rwasm@v1 with: - name: rwasmrepo - path: _site - - # Upload a tar file that will work with GitHub Pages - # Make sure to set a retention day to avoid running into a cap - # This artifact shouldn't be required after deployment onto pages was a success. + packages: "." + repo-path: "_site" + + # Upload an artifact that will work with GitHub Pages - name: Upload Pages artifact - uses: actions/upload-pages-artifact@v2 - - # Use an Action deploy to push the artifact onto GitHub Pages - # This requires the `Action` tab being structured to allow for deployment - # instead of using `docs/` or the `gh-pages` branch of the repository + if: github.event_name != 'pull_request' + uses: actions/upload-pages-artifact@v3 + with: + path: "_site" + + deploy: + if: github.event_name != 'pull_request' + needs: [build-site] + 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@v2 + uses: actions/deploy-pages@v1 From 5aca2c3ced3350c60365551d3c4c7b88d52ed2ab Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 2 Apr 2024 13:19:45 -0400 Subject: [PATCH 4/4] Use `actions/deploy-pages@v4` --- examples/rwasm-binary-and-pkgdown-site.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rwasm-binary-and-pkgdown-site.yml b/examples/rwasm-binary-and-pkgdown-site.yml index 32aba94..ccb0b36 100644 --- a/examples/rwasm-binary-and-pkgdown-site.yml +++ b/examples/rwasm-binary-and-pkgdown-site.yml @@ -65,4 +65,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 + uses: actions/deploy-pages@v4