Skip to content

Commit

Permalink
Merge pull request #19 from Sage-Bionetworks/improve-shinyapps-io-deploy
Browse files Browse the repository at this point in the history
Improve shinyapps io deploy
  • Loading branch information
avanlinden authored Aug 22, 2024
2 parents ed8b440 + 3b1a8a0 commit b87e258
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
34 changes: 14 additions & 20 deletions .github/workflows/deploy-shinyapps-io.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help

name: shinyapps-io-deploy
Expand All @@ -14,29 +14,23 @@ jobs:
shinyapps-io-deploy:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y pip python3-venv libcurl4-openssl-dev
- uses: r-lib/actions/setup-pandoc@v2

- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: disable renv
run: |
rm .Rprofile
rm renv.lock
rm -rf renv
- uses: r-lib/actions/setup-renv@v2

- name: Install R packages
run: |
# The binary package distributions from R Studio dramatically speed up installation time
options(repos = c(REPO_NAME = "https://packagemanager.rstudio.com/all/__linux__/focal/latest",
getOption("repos")))
install.packages(c("dplyr", "purrr", "reactable", "shiny", "rsconnect", "rjson", "httr"))
shell: sudo Rscript {0} # running this step as 'sudo' is necessary to be able to install packages in default library
- name: Install rsconnect
run: install.packages("rsconnect")
shell: Rscript {0}

- name: Authorize and deploy app
run: |
Expand All @@ -50,7 +44,7 @@ jobs:
rsConnectToken <- "${{ secrets.RSCONNECT_TOKEN }}"
rsConnectSecret <- "${{ secrets.RSCONNECT_SECRET }}"
rsconnect::setAccountInfo(rsConnectUser, rsConnectToken, rsConnectSecret)
appFiles<-dir(all.files=TRUE, include.dirs=TRUE)
rsconnect::deployApp(appName = appName, appFiles=appFiles, forceUpdate = TRUE)
# appDir default is current working directory
rsconnect::deployApp(appName = appName, forceUpdate = TRUE)
# important NOT to run this step as sudo, otherwise env var's will be missing
shell: Rscript {0}
6 changes: 6 additions & 0 deletions .rscignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
renv/
.Rprofile
.git/
.Rproj.user/
*.Rproj
*.log
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
# AMP-AD Metadata Dictionary

Hosts the dictionary used for metadata in AMP-AD, which is composed of the
[synapseAnnotations](https://github.com/Sage-Bionetworks/synapseAnnotations/) as
well as some custom values that are used only in metadata files, and not as
annotations.
Hosts the dictionary used for metadata in AMP-AD, which is a ReacTable object that displays the production [ADKP data model](https://github.com/adknowledgeportal/data-models/blob/main/AD.model.csv).

The dictionary app displays all attributes used as manifest columns, and all valid values for those columns. It does not display manifest attributes (where Parent = 'ManifestTemplate').

As of August 2024, this app no longer interacts with Synapse since it is pulling from the ADKP data model used for schematic and DCA. The recitulate and synapsclient dependencies have been removed.

### To deploy to ShinyApps.io:

- Enable workflows in the GitHub repository
- Under [secrets](https://github.com/Sage-Bionetworks/amp-ad-metadata-dictionary/settings/secrets/actions) click 'New repository secret'
- Enter secrets for `RSCONNECT_USER`, `RSCONNECT_TOKEN`, and `RSCONNECT_SECRET`, the values for which are saved in Sage's LastPass.
- Push to new branch on Github
- Create pull request with at least one reviewer to master branch
- Upon merge of pull request, the app will deploy to staging.
The shinyapps.io deployment workflow is `deploy-shinyapps-io.yaml`.
- This uses repository secrets to deploy the app to ShinyApps.io via rsconnect: `RSCONNECT_USER`, `RSCONNECT_TOKEN`, and `RSCONNECT_SECRET`. Values for these are saved in Sage's LastPass.
- This workflow runs when a PR is approved and merged into, OR via manual workflow dispatch
- Upon completion of the workflow, the app will deploy to staging.
Check out the app here: https://sagebio.shinyapps.io/amp-ad-metadata-dictionary-staging.
- After verifying correctness, create pull request with at least one reviewer to prod branch
- After verifying correctness on `main`, create pull request with at least one reviewer to `prod` branch
- Upon merge of pull request, the app will deploy to production.
- The app' will become available at https://sagebio.shinyapps.io/amp-ad-metadata-dictionary
- The production app will become available at https://sagebio.shinyapps.io/amp-ad-metadata-dictionary
- This app is embedded as an iframe on the Synapse wiki here: https://www.synapse.org/Synapse:syn25878249

### To deploy to Github Pages via shinylive:

The shinylive deployment workflow is `deploy-shinylive.yaml`.
- This uses the `shinylive` package to build a static site that is run entirely in the browser (https://posit-dev.github.io/r-shinylive/), and deploy that site to Github pages
- This workflow runs on a push to `main` or via workflow dispatch
- ⚠️ right now this site loads very, very slowly. The static site will not replace the shinyapps.io deployment as our user-facing version unless we can figure out how to speed it up.

0 comments on commit b87e258

Please sign in to comment.