-
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.
Merge pull request #5 from miraisolutions/feature/revamp-ci-cd-action…
…s-workflow Major refresh of CI-CD workflow and deployment setup
- Loading branch information
Showing
8 changed files
with
62 additions
and
47 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
|
||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" |
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,45 @@ | ||
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 | ||
# rsconnect is stricter than pak and would complain, see https://github.com/r-lib/pak/issues/485 | ||
PKG_INCLUDE_LINKINGTO: true | ||
|
||
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.Rproj.user | ||
.Rhistory | ||
rsconnect |
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
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
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 | ||
) |