Skip to content

Commit d1c82ef

Browse files
committed
chore: metadata: RHIDP-1502 generate build metadata (repo, pull req #, commit SHA and build time) while creating the docker images
Signed-off-by: Nick Boldt <[email protected]>
1 parent 8cdd043 commit d1c82ef

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

.github/workflows/next-docker-build.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ jobs:
4040
with:
4141
fetch-depth: 0
4242

43+
- name: Get the last commit short SHA
44+
run: |
45+
SHORT_SHA=$(git rev-parse --short HEAD)
46+
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
47+
if [[ -f packages/app/src/build-metadata.json ]]; then
48+
repo="${{ github.repository }}"
49+
now="$(date -u +%FT%TZ)"
50+
sed -i packages/app/src/build-metadata.json -r \
51+
-e 's|("Last Commit:.+)|"Last Commit: '$repo' @ '$SHORT_SHA'"|'
52+
fi
53+
4354
- name: Build and Push with Buildx
4455
uses: ./.github/actions/docker-build
4556
with:

.github/workflows/pr-docker-build.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ jobs:
5151
run: |
5252
SHORT_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})
5353
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
54+
if [[ -f packages/app/src/build-metadata.json ]]; then
55+
repoPR="${{ github.repository }}/pull/${{ github.event.number }}"
56+
now="$(date -u +%FT%TZ)"
57+
sed -i packages/app/src/build-metadata.json -r \
58+
-e 's|("Last Commit:.+)|"Last Commit: '$repoPR' @ '$SHORT_SHA'"|'
59+
fi
5460
5561
- name: Build and Push with Buildx
5662
uses: ./.github/actions/docker-build

.husky/pre-commit

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run versions:metadata
54
npm run lint-staged

scripts/update-metadata.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function updateBuildMetadata(backstageVersion) {
3131
const card = [
3232
`RHDH Version: ${rhdhVersion}`,
3333
`Backstage Version: ${backstageVersion}`,
34-
`Last Commit: ${commitTime}`,
34+
`Last Commit: repo @ ${commitTime}`,
3535
];
3636
buildMetadata.card = card;
3737

0 commit comments

Comments
 (0)