Skip to content

Commit

Permalink
add files to be submitted to shinyapps.io
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherMarais committed Feb 25, 2024
1 parent 2aff089 commit ae6f261
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 05_DASHBOARD/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ find_directory_of_file <- function(file_name, start_dir=getwd()) {

# find file_name from current working directory
# before trying from a shallower directory
file_name <- "*05_DASHBOARD/app.R" # The file you are searching for
file_name <- "*DASHBOARD/app.R" # The file you are searching for

try({
found_dir <- find_directory_of_file(file_name)
Expand Down
24 changes: 23 additions & 1 deletion 05_DASHBOARD/deploy-dev.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
# Load the rsconnect package
library(rsconnect)

# a function to list all files in a directory and its subdirectories
list_all_files <- function(directories) {
all_files <- c() # Initialize an empty vector to store all file paths

# Loop through each directory provided
for (dir in directories) {
if (!dir.exists(dir)) {
next # Skip if directory does not exist
}

# Use list.files to recursively list all files in the directory and its subdirectories
# full.names = TRUE returns the full paths, which is what we want
files <- list.files(dir, recursive = TRUE, full.names = TRUE)

# Append the files found to the all_files vector
all_files <- c(all_files, files)
}

return(all_files)
}

# Authenticate
rsconnect::setAccountInfo(
name = Sys.getenv("SHINY_ACC_NAME"),
token = Sys.getenv("SHINY_TOKEN"),
secret = Sys.getenv("SHINY_SECRET"))

# Deploy
req_files <- list_all_files(c("./04_Tests", "./03_Data_for_app")) # get all the required files
rsconnect::deployApp(
appDir = "./05_DASHBOARD",
appFiles = "app.R",
appFiles = c("app.R", req_files),
appName = "Dashboard-dev",
forceUpdate = TRUE)

0 comments on commit ae6f261

Please sign in to comment.