From 87c77469c245516b19f9ffe400c62be78b6b1ec3 Mon Sep 17 00:00:00 2001 From: Luke Symes Date: Fri, 16 Aug 2024 11:13:09 +1200 Subject: [PATCH] Customise deployment shinylive command --- .github/workflows/deploy-app.yaml | 59 +++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-app.yaml b/.github/workflows/deploy-app.yaml index 1610a76..8075078 100644 --- a/.github/workflows/deploy-app.yaml +++ b/.github/workflows/deploy-app.yaml @@ -15,9 +15,64 @@ on: pull_request: jobs: - shinylive: - uses: posit-dev/r-shinylive/.github/workflows/deploy-app.yaml@actions-v1 + build: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: rstudio/shiny-workflows/setup-r-package@v1 + with: + packages: | + renv + posit-dev/r-shinylive + sessioninfo + cache-version: ${{ github.event.inputs.cache-version }} + + - name: Find package dependencies + shell: Rscript {0} + id: packages + run: | + # Find package dependencies using {renv} and install with {pak} + pak::pak( + unique(renv::dependencies(".")$Package) + ) + + - name: Build site + shell: Rscript {0} + run: | + shinylive::export( + ".", "site", wasm_packages = FALSE, package_cache = FALSE, + template_params = list(title = "IncomeExplorer", + include_in_head = tags$link(rel = "shortcut icon", href = "favicon.ico")) + ) + + - name: Upload site artifact + if: github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v3 + with: + path: "site" + + deploy: + if: github.ref == 'refs/heads/main' + needs: build + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: pages: write # to deploy to Pages id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4ce