Skip to content

Commit 87adb64

Browse files
authored
Add DCA and Schematic versions to footer of dashboard. (#564)
* 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
1 parent 1c131a0 commit 87adb64

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

.github/workflows/docker_build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
env:
1515
REGISTRY: ghcr.io
1616
IMAGE_PATH: ghcr.io/${{ github.repository }}
17+
DCA_VERSION: ${{ github.REF_NAME }}
1718

1819
jobs:
1920
build-and-push-image:
@@ -50,3 +51,6 @@ jobs:
5051
push: true
5152
tags: ${{ steps.meta.outputs.tags }}
5253
labels: ${{ steps.meta.outputs.labels }}
54+
build-args: |
55+
DCA_VERSION=${{ env.DCA_VERSION }}
56+

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
FROM ghcr.io/afwillia/shiny-base:release-update-node
2-
LABEL maintainer="Anthony anthony.williams@sagebase.org"
2+
3+
# add version tag as a build argument
4+
ARG DCA_VERSION
5+
6+
ENV DCA_VERSION=$DCA_VERSION
37

48
USER root
59
RUN apt-get update

dca_startup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Pass environment variable to Shiny
44
echo "" >> .Renviron
55
echo R_CONFIG_ACTIVE=$R_CONFIG_ACTIVE >> .Renviron
6+
echo DCA_VERSION=$DCA_VERSION >> .Renviron
67

78
# Now run the base start-up script
89
./startup.sh

global.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,18 @@ if (dca_schematic_api == "rest") {
6161
Sys.getenv("DCA_API_PORT"),
6262
sep = ":")
6363
)
64+
65+
# Get Schematic version
66+
get_schematic_version <- try(httr::GET(file.path(api_uri, "v1/version")), silent=TRUE)
67+
if (inherits(get_schematic_version, "try-error")) {
68+
schematic_version <- ""
69+
} else if (httr::http_error(get_schematic_version)) {
70+
schematic_version <- ""
71+
} else schematic_version <- httr::content(get_schematic_version)
6472
}
6573

74+
dca_version <- Sys.getenv("DCA_VERSION")
75+
6676
dca_synapse_api <- Sys.getenv("DCA_SYNAPSE_PROJECT_API")
6777

6878
# update port if running app locally

ui.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ ui <- shinydashboardPlus::dashboardPage(
294294
),
295295
# waiter loading screen
296296
dcWaiter("show", landing = TRUE)
297+
),
298+
footer = dashboardFooter(
299+
left = sprintf("DCA %s - Schematic %s", dca_version, schematic_version)
297300
)
298301
)
299302

0 commit comments

Comments
 (0)