-
Notifications
You must be signed in to change notification settings - Fork 18
88 lines (76 loc) · 2.46 KB
/
deploy-app.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Basic example of a GitHub Actions workflow that builds a Shiny app and deploys
# it to GitHub Pages.
#
# The agreed upon contract is:
#
# - Inspect the root directory for package dependencies
# - Install R and the found packages
# - Export the Shiny app directory to `./site`
# - On push events, deploy the exported app to GitHub Pages
#
# If this contract is not met or could be easily improved for others,
# please open a new Issue https://github.com/posit-dev/r-shinylive/
#
# The _magic_ of this workflow is in the `shinylive::export()` function, which
# creates a static version of the Shiny app into the folder `./site`.
# The exported app folder is then uploaded and deployed to GitHub Pages.
#
# When deploying to GitHub Pages, be sure to have the appropriate write
# permissions for your token (`pages` and `id-token`).
name: Deploy app
on:
workflow_call:
inputs:
cache-version:
type: string
default: "1"
required: false
jobs:
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")
- 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@v4