Skip to content

Commit

Permalink
Adding git rev to site build
Browse files Browse the repository at this point in the history
  • Loading branch information
TBeijen committed Jul 28, 2024
1 parent 3282c0d commit 360aa7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
# Get the repository's code
- name: Checkout
uses: actions/checkout@v4
- name: Get short Git revision
id: gitrev
run: |
gitrev=$(git rev-parse --short HEAD)
echo "::set-output name=gitrev::$gitrev"
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -63,6 +68,8 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
build-args: |
GIT_REVISION=${{ steps.gitrev.outputs.gitrev}}
deploy:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# See: https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:alpine AS build

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG HUGO_VERSION="0.63.1"
ARG HUGO_ARCH="64bit"
ARG GIT_REVISION="sha-notset"

ENV GIT_REVISION_ENV=${GIT_REVISION}

RUN BUILD_ARCH_UC=$(echo $BUILDPLATFORM | awk -F'/' '{print $2}' | tr '[:lower:]' '[:upper:]') && \
if [ $BUILD_ARCH_UC == "ARM64" ]; then HUGO_ARCH="ARM64"; fi && \
Expand All @@ -19,6 +23,8 @@ WORKDIR /opt/tbnl

COPY . ./source

RUN sed -i -e "s/gitRevision.*=.*/gitRevision = \"${GIT_REVISION_ENV}\"/" ./source/config/generic/params.toml

RUN hugo -e generic --source=${PWD}/source --destination=${PWD}/build/generic

# Final image
Expand Down

0 comments on commit 360aa7b

Please sign in to comment.