From d3c992bec7dc8e9a4a88362249eb7c1cd9565ab4 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 4 Sep 2020 09:09:20 +0100 Subject: [PATCH] Print version, date and revision --- .automation/upload-docker.sh | 5 +++-- Dockerfile | 9 +++++++++ lib/linter.sh | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index db1fde0b..1234f0b9 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -39,6 +39,7 @@ CONTAINER_URL='' # Final URL to upload # Dynamic build variables to pass to container when built # ########################################################### BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') # Current build date EX> "2017-08-28T09:24:41Z" +BUILD_REVISION=$(git rev-parse --short HEAD)# Current git commit EX> "e89faa7" BUILD_VERSION='' # Current version of the container being built ######################### @@ -303,7 +304,7 @@ BuildImage() { ################### # Build the image # ################### - docker build --no-cache --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_VERSION=${BUILD_VERSION}" -t "${CONTAINER_URL}:${IMAGE_VERSION}" -f "${DOCKERFILE_PATH}" . 2>&1 + docker build --no-cache --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_REVISION=${BUILD_REVISION}" --build-arg "BUILD_VERSION=${BUILD_VERSION}" -t "${CONTAINER_URL}:${IMAGE_VERSION}" -f "${DOCKERFILE_PATH}" . 2>&1 ####################### # Load the error code # @@ -326,7 +327,7 @@ BuildImage() { ######################################################## if [ ${UPDATE_MAJOR_TAG} -eq 1 ]; then # Tag the image with the major tag as well - docker build --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_VERSION=${MAJOR_TAG}" -t "${CONTAINER_URL}:${MAJOR_TAG}" -f "${DOCKERFILE_PATH}" . 2>&1 + docker build --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_REVISION=${BUILD_REVISION}" --build-arg "BUILD_VERSION=${MAJOR_TAG}" -t "${CONTAINER_URL}:${MAJOR_TAG}" -f "${DOCKERFILE_PATH}" . 2>&1 ####################### # Load the error code # diff --git a/Dockerfile b/Dockerfile index c16a26d3..7b737996 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ FROM python:alpine # Get the build arguements # ############################ ARG BUILD_DATE +ARG BUILD_REVISION ARG BUILD_VERSION ######################################### @@ -39,6 +40,7 @@ LABEL com.github.actions.name="GitHub Super-Linter" \ com.github.actions.color="red" \ maintainer="GitHub DevOps " \ org.opencontainers.image.created=$BUILD_DATE \ + org.opencontainers.image.revision=$BUILD_REVISION \ org.opencontainers.image.version=$BUILD_VERSION \ org.opencontainers.image.authors="GitHub DevOps " \ org.opencontainers.image.url="https://github.com/github/super-linter" \ @@ -46,6 +48,13 @@ LABEL com.github.actions.name="GitHub Super-Linter" \ org.opencontainers.image.vendor="GitHub" \ org.opencontainers.image.description="Lint your code base with GitHub Actions" +################################################# +# Set ENV values used for debugging the version # +################################################# +ENV BUILD_DATE=$BUILD_DATE +ENV BUILD_REVISION=$BUILD_REVISION +ENV BUILD_VERSION=$BUILD_VERSION + ################################ # Set ARG values used in Build # ################################ diff --git a/lib/linter.sh b/lib/linter.sh index 08edb0e6..e50544d7 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -437,6 +437,9 @@ Header() { ########## info "---------------------------------------------" info "--- GitHub Actions Multi Language Linter ----" + info " created date: ${BUILD_DATE}" + info " revision: ${BUILD_REVISION}" + info " version: ${BUILD_VERSION}" info "---------------------------------------------" info "---------------------------------------------" info "The Super-Linter source code can be found at:"