Skip to content

Commit 01d163f

Browse files
pjonssonomad
authored andcommitted
CI: fixate time stamp for image layers
Set the timestamp of the layers in the Docker image according to: https://docs.docker.com/build/ci/github-actions/reproducible-builds/ We improve on that solution by just getting the time of the last commit for the package-related files, so timestamps change less often.
1 parent 4724626 commit 01d163f

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

.github/workflows/scan.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
- name: Set up Docker Buildx
3636
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
3737

38+
- name: Get Git commit timestamps
39+
run: |
40+
TIMESTAMP=$(git log -1 --pretty=%ct pyproject.toml uv.lock cubedash)
41+
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV
42+
3843
- name: Build Docker
3944
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
4045
with:
@@ -44,6 +49,8 @@ jobs:
4449
load: true
4550
cache-from: type=gha
4651
cache-to: type=gha,mode=max
52+
env:
53+
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
4754

4855
- name: Run vulnerability scanner
4956
uses: aquasecurity/trivy-action@dc5a429b52fcf669ce959baa2c2dd26090d2a6c4 # master

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ jobs:
3838
- name: Set up Docker Buildx
3939
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
4040

41+
- name: Get Git commit timestamps
42+
run: |
43+
TIMESTAMP=$(git log -1 --pretty=%ct pyproject.toml uv.lock cubedash)
44+
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV
45+
4146
- name: Build Docker
4247
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
4348
with:
@@ -49,6 +54,8 @@ jobs:
4954
load: true
5055
cache-from: type=gha
5156
cache-to: type=gha,mode=max
57+
env:
58+
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
5259

5360
- name: Run tests
5461
run: |

0 commit comments

Comments
 (0)