Skip to content

Commit

Permalink
Docker GHA: Add commit time
Browse files Browse the repository at this point in the history
Also get the tag from the release downloaded to set the corresponding
commit sha and date
  • Loading branch information
quartje committed Jan 24, 2024
1 parent c854314 commit 5c3f26d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
tags: true

- name: Get the latest release
id: release
Expand All @@ -19,6 +22,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

Expand Down Expand Up @@ -49,7 +60,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
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5c3f26d

Please sign in to comment.