-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0882428
commit 9003fb9
Showing
5 changed files
with
214 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Run on push to dev | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push to the dev branch. | ||
push: | ||
branches: | ||
- dev | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v3 | ||
|
||
# build the docker image and give it the name main | ||
- name: Build image | ||
run: docker build -t dev -f inst/deploy_app/Dockerfile . | ||
# run the docker image supply the secrets from the github secrets store. | ||
- name: execute | ||
run: > | ||
docker run | ||
-e SHINY_ACC_NAME=${{secrets.SHINY_ACC_NAME}} | ||
-e SHINY_ACC_TOKEN=${{secrets.SHINY_ACC_TOKEN}} | ||
-e SHINY_ACC_SECRET=${{secrets.SHINY_ACC_SECRET}} | ||
-e SHINY_APP_NAME="unmetneeds" | ||
-e BRANCH_NAME="dev" | ||
dev |
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,37 @@ | ||
name: Run on push or pull request merge to main | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push events but only for the main branch. | ||
push: | ||
branches: | ||
- main | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v3 | ||
|
||
# build the docker image and give it the name main | ||
- name: Build image | ||
run: docker build -t main -f inst/deploy_app/Dockerfile . | ||
# run the docker image supply the secrets from the github secrets store. | ||
- name: execute | ||
run: > | ||
docker run | ||
-e SHINY_ACC_NAME=${{secrets.SHINY_ACC_NAME}} | ||
-e SHINY_ACC_TOKEN=${{secrets.SHINY_ACC_TOKEN}} | ||
-e SHINY_ACC_SECRET=${{secrets.SHINY_ACC_SECRET}} | ||
-e SHINY_APP_NAME="unmetneeds" | ||
-e BRANCH_NAME="main" | ||
main |
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,37 @@ | ||
name: Run on push or pull request merge to main | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on pull request events but only for the main branch. | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v3 | ||
|
||
# build the docker image and give it the name main | ||
- name: Build image | ||
run: docker build -t main_PR -f inst/deploy_app/Dockerfile . | ||
# run the docker image supply the secrets from the github secrets store. | ||
- name: execute | ||
run: > | ||
docker run | ||
-e SHINY_ACC_NAME=${{secrets.SHINY_ACC_NAME}} | ||
-e SHINY_ACC_TOKEN=${{secrets.SHINY_ACC_TOKEN}} | ||
-e SHINY_ACC_SECRET=${{secrets.SHINY_ACC_SECRET}} | ||
-e SHINY_APP_NAME="unmetneeds_PR" | ||
-e BRANCH_NAME=${{github.base_ref}}" | ||
main_PR |
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,56 @@ | ||
# Get the rocker image, latest shiny from rocker in this case: | ||
# Base image https://hub.docker.com/u/rocker/ | ||
# For latest version use: FROM rocker/shiny:latest | ||
FROM rocker/shiny-verse:4.3 | ||
|
||
# system libraries of general use | ||
## install debian packages | ||
RUN apt-get update -qq && apt-get -y --no-install-recommends install \ | ||
libxml2-dev \ | ||
libcairo2-dev \ | ||
libsqlite3-dev \ | ||
libmariadbd-dev \ | ||
libpq-dev \ | ||
libssh2-1-dev \ | ||
unixodbc-dev \ | ||
libcurl4-openssl-dev \ | ||
libssl-dev | ||
|
||
## update system libraries | ||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get clean | ||
|
||
# Install package remotes [to allow installGithub.r for github packages]: | ||
RUN install2.r data.table remotes devtools rlang rmapshaper sf sp here \ | ||
methods assertthat leaflet leaflet.extras DT \ | ||
shinydashboard shinyWidgets shinyjs | ||
|
||
# Create a working directory in the image: | ||
WORKDIR /home/shinyusr | ||
|
||
# Copy the folder "app" (containing the shiny app) to the working directory ".": | ||
COPY inst/app app | ||
|
||
# Copy the deployment script from the deployment folder to the working dircetory: | ||
COPY inst/deploy_app/deploy.R deploy.R | ||
|
||
# Set the command to run once the container runs: | ||
CMD Rscript deploy.R | ||
|
||
### Notes: | ||
## To build this file with the name "test1": | ||
# 1. make sure this file is on project root | ||
# 2. navigate to R's local terminal and execute: | ||
# docker build -t test1 -f deploy-shiny/DockerfileDev . | ||
# 3. if the docker file was in root directory: | ||
# docker build -t test1 . | ||
# 4. if the build exists, this can be overriden: | ||
# docker build --no-cache -t test1 -f deploy-shiny/DockerfileDev . | ||
|
||
## To run the image from the same terminal: | ||
# 1. if the imaage require environment vars and stored in ".Renviron" | ||
# docker run --env-file .Renviron test1 | ||
|
||
## In github actions (if test1 was the image name): | ||
# docker build -t test1 -f deploy-shiny/DockerfileDev . |
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,47 @@ | ||
# Install old rsconnect to solve existing app error: | ||
remotes::install_version("rsconnect", "0.8.29") | ||
|
||
# Install private package:---- | ||
# devtools::install_github( | ||
# repo = paste0( | ||
# 'W-Mohammed/ShinyNeeds@', | ||
# Sys.getenv('BRANCH_NAME') | ||
# ), | ||
# auth_token = Sys.getenv('PRIVATE_REPO_TOKEN') | ||
# ) | ||
# Install public package:---- | ||
devtools::install_github( | ||
repo = paste0( | ||
'dark-peak-analytics/unmet-needs@', | ||
Sys.getenv('BRANCH_NAME') | ||
) | ||
) | ||
|
||
# Load two libraries:---- | ||
library(UnmetNeeds) | ||
library(rsconnect) | ||
|
||
# Authenticate:---- | ||
rsconnect::setAccountInfo( | ||
name = UnmetNeeds::error_on_missing_name("SHINY_ACC_NAME"), | ||
token = UnmetNeeds::error_on_missing_name("SHINY_ACC_TOKEN"), | ||
secret = UnmetNeeds::error_on_missing_name("SHINY_ACC_SECRET") | ||
) | ||
|
||
# Deploy the application:---- | ||
rsconnect::deployApp( | ||
appDir = file.path( | ||
here::here(), | ||
"app" | ||
), | ||
appFiles = NULL, | ||
#c("app.R" #, you can specify which files to deploy, | ||
#or keep this NULL to deploy everything) | ||
|
||
appName = paste0( | ||
UnmetNeeds::error_on_missing_name("SHINY_APP_NAME"), | ||
"_", | ||
UnmetNeeds::error_on_missing_name("BRANCH_NAME")), | ||
appTitle = "Unmet Needs Tool", | ||
forceUpdate = TRUE | ||
) |