-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refresh of CI-CD workflow and deployment setup
* Based on miraisolutions/ShinyCICD#19
- Loading branch information
1 parent
53b2d17
commit 7949c0c
Showing
4 changed files
with
49 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
^rTRhexNG\.Rproj$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^app\.R$ | ||
^\.travis\.yml$ | ||
^\.github$ | ||
^app\.R$ | ||
^R/_disable_autoload\.R$ | ||
^deploy$ | ||
^rsconnect$ | ||
^\.rscignore$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,43 @@ | ||
on: [push, pull_request] | ||
|
||
name: CI-CD | ||
|
||
on: | ||
# Triggered on push and pull request events | ||
push: | ||
pull_request: | ||
# Allow manual runs | ||
workflow_dispatch: | ||
# Monthly runs on the 1st day of the month at midnight | ||
schedule: | ||
- cron: '0 0 1 * *' | ||
|
||
jobs: | ||
CI-CD: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v2 | ||
env: | ||
# Access token for GitHub | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
# Preserve package sources for informative references in case of errors | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
|
||
- uses: r-lib/actions/setup-r@master | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Query dependencies | ||
run: | | ||
install.packages("remotes") | ||
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2) | ||
shell: Rscript {0} | ||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- name: Cache R packages | ||
uses: actions/cache@v1 | ||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
path: ${{ env.R_LIBS_USER }} | ||
key: ${{ runner.os }}-r-${{ hashFiles('depends.Rds') }} | ||
restore-keys: ${{ runner.os }}-r- | ||
extra-packages: any::rcmdcheck, any::rsconnect | ||
|
||
- name: Install system dependencies | ||
env: | ||
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc | ||
run: | | ||
Rscript -e "remotes::install_github('r-hub/sysreqs')" | ||
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") | ||
sudo -s eval "$sysreqs" | ||
# rsconnect dependencies | ||
sudo apt-get update && sudo apt-get install -y --no-install-recommends \ | ||
libxml2-dev libcurl4-openssl-dev | ||
- name: Install dependencies | ||
run: | | ||
remotes::install_deps(dependencies = TRUE) | ||
remotes::install_cran(c("rcmdcheck", "rsconnect")) | ||
shell: Rscript {0} | ||
|
||
- name: Check | ||
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check") | ||
shell: Rscript {0} | ||
- uses: r-lib/actions/check-r-package@v2 | ||
|
||
- name: Deploy to shinyapps.io | ||
if: github.ref == 'refs/heads/master' | ||
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | ||
env: | ||
SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }} | ||
SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }} | ||
SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }} | ||
run: | | ||
account_info <- lapply(paste0("SHINYAPPS_", c("ACCOUNT", "TOKEN", "SECRET")), Sys.getenv) | ||
do.call(rsconnect::setAccountInfo, account_info) | ||
rsconnect::deployApp(appName = "rTRhexNG") | ||
shell: Rscript {0} | ||
|
||
run: Rscript deploy/deploy-shinyapps.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Disabling shiny autoload | ||
|
||
# See ?shiny::loadSupport for more information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# deploy/deploy-shinyapps.R | ||
# usethis::use_build_ignore("deploy") | ||
if (!interactive()) { | ||
rsconnect::setAccountInfo( | ||
Sys.getenv("SHINYAPPS_ACCOUNT"), | ||
Sys.getenv("SHINYAPPS_TOKEN"), | ||
Sys.getenv("SHINYAPPS_SECRET") | ||
) | ||
} | ||
# Add here any additional files/directories the app needs | ||
app_files = c("app.R", "DESCRIPTION", "NAMESPACE", "R/", "inst/") | ||
rsconnect::deployApp( | ||
appName = "rTRhexNG", appFiles = app_files, forceUpdate = TRUE | ||
) |