Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: annotations, labels and tags output in container-build-push-generic action #1160

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading