From 571a18524dca872761f003cd03b38c6cd0ec28c1 Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Wed, 24 Jan 2024 14:47:44 +0100 Subject: [PATCH] Docker GHA: Add commit time Also get the tag from the release downloaded to set the corresponding commit sha and date --- .github/workflows/build-push-docker-image.yml | 11 ++++++++++- docker/Dockerfile.prod | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-push-docker-image.yml b/.github/workflows/build-push-docker-image.yml index 334fc0274..b6bc7fe77 100644 --- a/.github/workflows/build-push-docker-image.yml +++ b/.github/workflows/build-push-docker-image.yml @@ -19,6 +19,14 @@ jobs: latest: true fileName: "*.tar.bz2" + - name: Get commit details for the tag from the latest release + id: commit_details + run: | + GIT_SHA=$(git rev-list -n 1 ${{ steps.release.outputs.tag_name }}) + GIT_COMMIT_TIME=$(git show -s --format=%ci ${{ steps.release.outputs.tag_name }}) + echo "::set-output name=sha::$GIT_SHA" + echo "::set-output name=commit_time::$GIT_COMMIT_TIME" + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -49,7 +57,8 @@ jobs: context: . build-args: | APP_VERSION=${{ steps.release.outputs.tag_name }} - GIT_SHA=${{ github.sha }} + GIT_SHA=${{ steps.commit_details.outputs.sha }} + GIT_COMMIT_TIME=${{ steps.commit_details.outputs.commit_time }} file: docker/Dockerfile.prod platforms: linux/amd64,linux/arm64 push: true diff --git a/docker/Dockerfile.prod b/docker/Dockerfile.prod index 42e8e5cc4..fffd06454 100644 --- a/docker/Dockerfile.prod +++ b/docker/Dockerfile.prod @@ -1,8 +1,10 @@ FROM ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest ARG APP_VERSION ARG GIT_SHA +ARG GIT_COMMIT_TIME ENV OPENCONEXT_APP_VERSION=${APP_VERSION} ENV OPENCONEXT_GIT_SHA=${GIT_SHA} +ENV OPENCONEXT_GIT_DATE=${GIT_COMMIT_TIME} # Set the default workdir WORKDIR /var/www/html