From 28f31e4ae441dbfbd9f652fd8eda632cdf0c826c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Tue, 2 Apr 2024 12:58:38 -0400 Subject: [PATCH] docs: Use r-wasm/actions wasm+pkgdown example (#23) * Use r-wasm/actions wasm+pkgdown example from r-wasm/actions#17 * Update pkgdown.yaml --- .github/workflows/pkgdown.yaml | 62 +++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index b5aac87..e30b285 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,48 +1,70 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# 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: - branches: [main, master, pkg] + branches: [main, pkg] pull_request: - branches: [main, master, pkg] release: types: [published] workflow_dispatch: -name: pkgdown +name: R Wasm & pkgdown deploy jobs: - pkgdown: + build-site: 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 }} - permissions: - contents: write + steps: - - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 + # Usual steps for generating a pkgdown website - 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 to `_site` - name: Build site - run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} + run: | + pkgdown::build_site_github_pages( + new_process = FALSE, + install = FALSE, + dest_dir = "_site" + ) - - name: Deploy to GitHub pages 🚀 + # 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 an artifact that will work with GitHub Pages + - name: Upload Pages artifact if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: actions/upload-pages-artifact@v3 with: - clean: false - branch: gh-pages - folder: docs + 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@v1