Skip to content

Commit fd44c1b

Browse files
authored
ci: set timestamp for reproducible Docker builds (#745)
Introduces a step to retrieve the latest git commit timestamp and store it in the environment. This timestamp is used as `SOURCE_DATE_EPOCH` during Docker image build to ensure reproducible builds by standardizing the build date. This change improves build consistency and traceability. https://docs.docker.com/build/ci/github-actions/reproducible-builds/
1 parent f14e941 commit fd44c1b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

.github/workflows/test_build_push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ jobs:
6666
- name: Set up Docker Buildx
6767
uses: docker/setup-buildx-action@v3
6868

69+
- name: Get Git commit timestamps
70+
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
71+
6972
- name: Log in to DockerHub
7073
uses: docker/login-action@v3
7174
with:
@@ -82,6 +85,8 @@ jobs:
8285
8386
- name: Build and push Docker image
8487
uses: docker/build-push-action@v5
88+
env:
89+
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
8590
with:
8691
context: .
8792
push: true

0 commit comments

Comments
 (0)