Skip to content

Commit

Permalink
ci: pin debian container based on commit date
Browse files Browse the repository at this point in the history
The ci container is based on a reproducible debian base container.
This container was selected based on the most recent tag for the
requested distribution (e.g. bookworm-<date>-slim). However, when
re-building old tags in the CI, the selected date needs to match the
commit date and not the current date. This logic is implemented in this
patch.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed May 14, 2024
1 parent c9f700e commit bc9a636
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/actions/docker-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ runs:

- name: Determine Debian tag
run: |
COMMIT_DATE=$(date -d @$(git log -1 --pretty=%ct) +%Y%m%d)
DEBIAN_RELEASE=$(grep -m 1 'ARG DEBIAN_TAG=' Dockerfile | sed 's/.*DEBIAN_TAG=\(.*\)-.*/\1/')
echo "DEBIAN_TAG=$(podman image search --list-tags debian --limit 1000000000 | \
grep "$DEBIAN_RELEASE-.*-slim" | sort -r | head -1 | sed 's/.*[ ]\+//')" >> $GITHUB_ENV
echo "DEBIAN_TAG=$(podman search --list-tags docker.io/debian --limit 1000000000 | \
grep "$DEBIAN_RELEASE-.*-slim" | sort -r | sed 's/.*[ ]\+//' | \
./scripts/lower-bound.py $DEBIAN_RELEASE-$COMMIT_DATE-slim )" \
>> $GITHUB_ENV
shell: bash

- name: Prepare repository for COPY-in
Expand Down
11 changes: 11 additions & 0 deletions scripts/lower-bound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3
# takes a reverse-sorted, line separated list and
# returns the first element that is equal or smaller
# than the first argument

import sys

for line in sys.stdin:
if line.rstrip() <= sys.argv[1]:
print(line.rstrip())
break

0 comments on commit bc9a636

Please # to comment.