Skip to content

Commit 5964658

Browse files
committed
feat: add context-hash to image tags for TAD traceability\n\nEach image is now tagged with both:\n - <version> (mutable, used by deps.yaml)\n - <version>-<hash> (immutable, for audit trail)\n\nThe hash is the first 8 chars of the git tree SHA of the build\ncontext directory. It changes if and only if any file in that\ndirectory changes, providing deterministic, traceable tags."
1 parent a5d8ed1 commit 5964658

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/build-mongodb-images.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,29 @@ jobs:
7171
username: ${{ github.repository_owner }}
7272
password: ${{ secrets.GITHUB_TOKEN }}
7373

74+
- name: Compute context hash
75+
id: context_hash
76+
run: |
77+
# Compute a short hash of the build-context directory tree.
78+
# This changes if and only if any file inside the context changes,
79+
# giving each image an immutable, traceable tag per TAD requirement.
80+
TREE_HASH=$(git rev-parse HEAD:${{ matrix.context }})
81+
SHORT_HASH=${TREE_HASH:0:8}
82+
echo "hash=${SHORT_HASH}" >> "$GITHUB_OUTPUT"
83+
echo "Context tree hash for ${{ matrix.name }}: ${TREE_HASH} (short: ${SHORT_HASH})"
84+
7485
- name: Build tags
7586
id: tags
7687
run: |
88+
# Mutable version tag (used by deps.yaml / deploy scripts)
7789
TAGS="${{ env.REGISTRY }}/${{ matrix.image }}:${{ matrix.semver_tag }}"
90+
# Immutable version-context-hash tag (TAD traceability)
91+
TAGS="${TAGS},${{ env.REGISTRY }}/${{ matrix.image }}:${{ matrix.semver_tag }}-${{ steps.context_hash.outputs.hash }}"
7892
if [[ -n "${{ matrix.minor_tag }}" ]]; then
7993
TAGS="${TAGS},${{ env.REGISTRY }}/${{ matrix.image }}:${{ matrix.minor_tag }}"
8094
fi
8195
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
96+
echo "Image tags: ${TAGS}"
8297
8398
- name: Build and push (${{ matrix.name }})
8499
uses: docker/build-push-action@v5

0 commit comments

Comments
 (0)