Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add md5 checksum of dockerfiles to image labels #967

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/docker-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: MD5 of Dockerfile
id: md5_result
run: |
echo "md5=$(md5sum "${{ matrix.dockerfile }}" | awk '{ print $1 }')" >> $GITHUB_OUTPUT

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
labels: |
rocks.goss.dockerfile-md5=${{ steps.md5_result.outputs.md5 }}

- name: Build and push tag
uses: docker/build-push-action@v5
Expand Down
2 changes: 2 additions & 0 deletions development/build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LABEL_REVISION=$(git rev-parse HEAD)
for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
[[ $docker_file == *.md5 ]] && continue
os=$(cut -d '_' -f2 <<<"$docker_file")
md5=$(md5sum "$docker_file" | awk '{ print $1 }')
docker build \
--label "org.opencontainers.image.created=$LABEL_DATE" \
--label "org.opencontainers.image.description=Quick and Easy server testing/validation" \
Expand All @@ -21,5 +22,6 @@ for docker_file in $INTEGRATION_TEST_DIR/Dockerfile_*; do
--label "org.opencontainers.image.title=goss" \
--label "org.opencontainers.image.url=$LABEL_URL" \
--label "org.opencontainers.image.version=manual" \
--label "rocks.goss.dockerfile-md5"=$md5 \
-t "aelsabbahy/goss_${os}:latest" - < "$docker_file"
done