Skip to content

Commit 5b5f786

Browse files
ostermankorenyoni
andauthored
Output metadata to job summary (#60)
* output metadata to job summary * output metadata to job summary * output metadata to job summary * output metadata to job summary * add option to inspect the image * add option to inspect the image * add option to inspect the image * add option to inspect the image --------- Co-authored-by: Yonatan Koren <[email protected]>
1 parent b914647 commit 5b5f786

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

.github/workflows/test-docker-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
registry: registry.hub.docker.com
3131
login: ${{ secrets.DOCKERHUB_USERNAME }}
3232
password: ${{ secrets.DOCKERHUB_PASSWORD }}
33+
inspect: true
3334
tags: |
3435
type=sha,format=long,suffix=-single-platform,priority=1002
3536

action.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ inputs:
9797
description: "Set to `true` to tag images with the PR HEAD SHA instead of the merge commit SHA within pull requests."
9898
required: false
9999
default: "false"
100+
inspect:
101+
description: "Set to `true` will pull and inspect the image and output it to the step summary."
102+
required: false
103+
default: "false"
100104
debug:
101105
description: "Enable debug mode"
102106
required: false
@@ -232,4 +236,21 @@ runs:
232236
run: |
233237
metadata=$(echo '${{ steps.docker-build-push-action.outputs.metadata }}' | jq -c)
234238
echo "metadata=$metadata" >> $GITHUB_OUTPUT
235-
echo "Docker image metadata: $metadata"
239+
echo "## Docker Image Metadata" >> $GITHUB_STEP_SUMMARY
240+
echo '```json' >> $GITHUB_STEP_SUMMARY
241+
echo "$metadata" | jq >> $GITHUB_STEP_SUMMARY
242+
echo '```' >> $GITHUB_STEP_SUMMARY
243+
244+
- name: Docker Inspect
245+
id: inspect
246+
if: ${{ inputs.inspect }} == 'true'
247+
shell: bash
248+
run: |
249+
docker pull "${{ inputs.registry }}/${{ steps.image_name.outputs.image_name }}:${{ steps.tag.outputs.output }}"
250+
docker inspect "${{ inputs.registry }}/${{ steps.image_name.outputs.image_name }}:${{ steps.tag.outputs.output }}" > inspect.json
251+
metadata=$(jq -c < inspect.json)
252+
echo "metadata=$metadata" >> $GITHUB_OUTPUT
253+
echo "## Docker Image Inspect" >> $GITHUB_STEP_SUMMARY
254+
echo '```json' >> $GITHUB_STEP_SUMMARY
255+
cat inspect.json >> $GITHUB_STEP_SUMMARY
256+
echo '```' >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)