Skip to content

Commit

Permalink
Add: annotations, labels and tags output in container-build-push-gene…
Browse files Browse the repository at this point in the history
…ric action (#1160)
  • Loading branch information
pascalholthaus committed Jun 28, 2024
1 parent 0574689 commit f11cc41
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
10 changes: 7 additions & 3 deletions container-build-push-generic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jobs:

## Action Output

| Output Variable | Description |
|-----------------|----------------------|
| digest | The container digest |
| Output Variable | Description |
|-----------------|---------------------------------|
| annotations | The container annotations. |
| digest | The container digest. |
| labels | The container labels. |
| meta-tags | The meta action container tags. |
| tags | The container tags. |
25 changes: 25 additions & 0 deletions container-build-push-generic/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,21 @@ inputs:
default: "false"

outputs:
annotations:
description: "The container annotations."
value: ${{ steps.meta.outputs.annotations }}
digest:
description: "The container digest."
value: ${{ steps.build-and-push.outputs.digest }}
labels:
description: "The container labels."
value: ${{ steps.meta.outputs.labels }}
tags:
description: "The container tags."
value: ${{ steps.tags.outputs.tags }}
meta-tags:
description: "The meta action container tags."
value: ${{ steps.meta.outputs.tags }}

branding:
icon: "package"
Expand Down Expand Up @@ -112,6 +124,19 @@ runs:
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: ${{ inputs.meta-annotations-levels }}

# We need to filter the tags here because the tags from the meta action contain the full URL.
# The full URL might include a secret, and secrets cannot be exposed in the output.
- name: Filter tags
id: tags
shell: bash
run: |
set +e ; IFS=$'\n' read -r -d '' -a tags <<< "$(printf '%s\n' '${{ steps.meta.outputs.tags }}' | sort -u)" ; set -e
echo 'tags<<EOF' >> $GITHUB_OUTPUT
for tag in "${tags[@]}"; do
echo "$tag" | cut -d ':' -f 2 >> $GITHUB_OUTPUT
done
echo 'EOF' >> $GITHUB_OUTPUT
- name: Build and push container image
id: build-and-push
uses: docker/build-push-action@v6
Expand Down

0 comments on commit f11cc41

Please sign in to comment.