Skip to content

Commit

Permalink
chore: metadata: RHIDP-1502 generate build metadata (repo, pull req #…
Browse files Browse the repository at this point in the history
…, commit SHA and build time) while creating the docker images

Signed-off-by: Nick Boldt <nboldt@redhat.com>
  • Loading branch information
nickboldt committed May 7, 2024
1 parent 8cdd043 commit d1c82ef
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/next-docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ jobs:
with:
fetch-depth: 0

- name: Get the last commit short SHA
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
if [[ -f packages/app/src/build-metadata.json ]]; then
repo="${{ github.repository }}"
now="$(date -u +%FT%TZ)"
sed -i packages/app/src/build-metadata.json -r \
-e 's|("Last Commit:.+)|"Last Commit: '$repo' @ '$SHORT_SHA'"|'
fi
- name: Build and Push with Buildx
uses: ./.github/actions/docker-build
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/pr-docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
run: |
SHORT_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
if [[ -f packages/app/src/build-metadata.json ]]; then
repoPR="${{ github.repository }}/pull/${{ github.event.number }}"
now="$(date -u +%FT%TZ)"
sed -i packages/app/src/build-metadata.json -r \
-e 's|("Last Commit:.+)|"Last Commit: '$repoPR' @ '$SHORT_SHA'"|'
fi
- name: Build and Push with Buildx
uses: ./.github/actions/docker-build
Expand Down
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run versions:metadata
npm run lint-staged
2 changes: 1 addition & 1 deletion scripts/update-metadata.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function updateBuildMetadata(backstageVersion) {
const card = [
`RHDH Version: ${rhdhVersion}`,
`Backstage Version: ${backstageVersion}`,
`Last Commit: ${commitTime}`,
`Last Commit: repo @ ${commitTime}`,
];
buildMetadata.card = card;

Expand Down

0 comments on commit d1c82ef

Please # to comment.