Skip to content

Commit

Permalink
ci: pass BUILD_COMMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
axelrindle committed Nov 28, 2024
1 parent 62b38c3 commit b97dd2c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:

- uses: actions/checkout@v4

- name: Get short SHA
id: sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
Expand All @@ -81,3 +85,5 @@ jobs:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_COMMIT=${{ steps.sha.outputs.sha_short }}
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM golang:1.23-alpine AS build

ARG BUILD_COMMIT

RUN apk add --no-cache \
curl \
git \
Expand All @@ -13,7 +15,7 @@ COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN task build:release
RUN task build:release "BUILD_COMMIT=${BUILD_COMMIT}"


FROM alpine:3
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tasks:
vars:
BUILD_VERSION: "{{ env \"BUILD_VERSION\" | default \"dev\" }}"
BUILD_COMMIT:
sh: git rev-parse --short HEAD
sh: echo "${BUILD_COMMIT:-$(git rev-parse --short HEAD)}"
env:
GOOS: linux
GOARCH: arm64
Expand Down

0 comments on commit b97dd2c

Please sign in to comment.