Skip to content

Commit

Permalink
Add DCA and Schematic versions to footer of dashboard. (#564)
Browse files Browse the repository at this point in the history
* WIP: Add DCA and Schematic versions to footer of dashboard.

* Get schematic version via api call

* Use schematic version from variable in global.R

* Add version as an env variable to docker container

* When building docker container, use the github ref as a build arg to note the version.

* Change version variable to DCA_VERSION

* Set DCA_VERSION env var to a variable in the global env

* Show DCA version from the env var

* Use GITHUB_REF_NAME env var to set version env var.

* specify github context for github_ref_name var

* Update github ref name to github.REF_NAME

* For clarity, set build arg to DCA_VERSION instead of TAG.

* Add DCA_VERSION env var to .Renviron so it is loaded as env var in shiny server.

* Make DCA_VERSION from docker build-arg an env var in the container. Then in dca_startup.sh, add the env var to Renviron

* Add error handling for schematic version api call
  • Loading branch information
afwillia authored Aug 24, 2023
1 parent 1c131a0 commit 87adb64
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_PATH: ghcr.io/${{ github.repository }}
DCA_VERSION: ${{ github.REF_NAME }}

jobs:
build-and-push-image:
Expand Down Expand Up @@ -50,3 +51,6 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
DCA_VERSION=${{ env.DCA_VERSION }}
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM ghcr.io/afwillia/shiny-base:release-update-node
LABEL maintainer="Anthony anthony.williams@sagebase.org"

# add version tag as a build argument
ARG DCA_VERSION

ENV DCA_VERSION=$DCA_VERSION

USER root
RUN apt-get update
Expand Down
1 change: 1 addition & 0 deletions dca_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Pass environment variable to Shiny
echo "" >> .Renviron
echo R_CONFIG_ACTIVE=$R_CONFIG_ACTIVE >> .Renviron
echo DCA_VERSION=$DCA_VERSION >> .Renviron

# Now run the base start-up script
./startup.sh
10 changes: 10 additions & 0 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@ if (dca_schematic_api == "rest") {
Sys.getenv("DCA_API_PORT"),
sep = ":")
)

# Get Schematic version
get_schematic_version <- try(httr::GET(file.path(api_uri, "v1/version")), silent=TRUE)
if (inherits(get_schematic_version, "try-error")) {
schematic_version <- ""
} else if (httr::http_error(get_schematic_version)) {
schematic_version <- ""
} else schematic_version <- httr::content(get_schematic_version)
}

dca_version <- Sys.getenv("DCA_VERSION")

dca_synapse_api <- Sys.getenv("DCA_SYNAPSE_PROJECT_API")

# update port if running app locally
Expand Down
3 changes: 3 additions & 0 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ ui <- shinydashboardPlus::dashboardPage(
),
# waiter loading screen
dcWaiter("show", landing = TRUE)
),
footer = dashboardFooter(
left = sprintf("DCA %s - Schematic %s", dca_version, schematic_version)
)
)

Expand Down

0 comments on commit 87adb64

Please sign in to comment.