posit-dev / r-shinylive

https://posit-dev.github.io/r-shinylive/
Other
151 stars 16 forks source link

Provide example workflow to deploy app to website #50

Closed schloerke closed 4 months ago

schloerke commented 7 months ago

TODO:

Example workflow:

name: Build app website

on:
  workflow_dispatch:
  push:
    branches: ["main"]
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - uses: rstudio/shiny-workflows/setup-r-package@v1
        with:
          packages: |
            shiny
            survival
            dplyr
            shinylive

      - name: Build site
        shell: Rscript {0}
        run: |
          shinylive::export(".", "site")

      - name: Upload site artifact
        if: github.ref == 'refs/heads/main'
        uses: actions/upload-pages-artifact@v1
        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@v1
georgestagg commented 5 months ago

The package list should be able to be retrieved using renv.