Skip to content

Commit

Permalink
Merge pull request #5 from miraisolutions/feature/revamp-ci-cd-action…
Browse files Browse the repository at this point in the history
…s-workflow

Major refresh of CI-CD workflow and deployment setup
  • Loading branch information
riccardoporreca authored Jan 31, 2024
2 parents 53b2d17 + 4d0fa33 commit 01a5f51
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 47 deletions.
9 changes: 6 additions & 3 deletions .Rbuildignore
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$
8 changes: 8 additions & 0 deletions .github/dependabot.yml
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"
70 changes: 28 additions & 42 deletions .github/workflows/ci-cd.yml
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.Rproj.user
.Rhistory
rsconnect
3 changes: 3 additions & 0 deletions R/_disable_autoload.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Disabling shiny autoload

# See ?shiny::loadSupport for more information
2 changes: 1 addition & 1 deletion R/rTRNG-stickR-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ ui <- function() {
12,
radioButtons("svg_postprocess", label = NULL, inline = TRUE,
choices = c("as-is", "rsvg", "rsvg2", "inkscape", "inkscape-text2path"),
selected = "rsvg2")
selected = "rsvg")
)
),

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# rTRhexNG: R-generated hexagon sticker for rTRNG

<!-- badges: start -->
[![R build status](https://github.com/miraisolutions/rTRhexNG/workflows/CI-CD/badge.svg)](https://github.com/miraisolutions/rTRhexNG/actions)
[![ci-cd](https://github.com/miraisolutions/rTRhexNG/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/miraisolutions/rTRhexNG/actions/workflows/ci-cd.yml)
<!-- badges: end -->

<img src="man/figures/rTRhexNG.gif" width="25%" height="25%"/>
Expand Down
14 changes: 14 additions & 0 deletions deploy/deploy-shinyapps.R
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
)

0 comments on commit 01a5f51

Please sign in to comment.