Skip to content

Commit 70cd8bf

Browse files
authored
Use a separate step to determine the image name as default or specified
1 parent 818a2e1 commit 70cd8bf

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

action.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ inputs:
3232
image_name:
3333
description: "Image name (excluding registry). Defaults to $organization/$repository"
3434
required: false
35-
# TODO: see if this works. If not, add a step to form this value.
36-
default: ${{ inputs.organization }}/${{ inputs.repository }}
35+
default: ''
3736
login:
3837
description: 'Docker login'
3938
required: false
@@ -59,21 +58,31 @@ inputs:
5958
outputs:
6059
image:
6160
description: "Docker image name"
62-
value: ${{ inputs.registry }}/${{ inputs.image_name }}
61+
value: ${{ inputs.registry }}/${{ steps.image_name.outputs.image_name }}
6362
tag:
6463
description: "Docker image tag"
6564
value: ${{ steps.tag.outputs.output }}
6665

6766
runs:
6867
using: "composite"
6968
steps:
69+
- name: Set image name
70+
if: ${{ inputs.image_name == '' }}
71+
id: image_name
72+
shell: bash
73+
run: |
74+
if [ "${{ inputs.image_name }}" = "" ]; then
75+
echo 'image_name=${{ inputs.organization }}/${{ inputs.repository }}' >> "$GITHUB_OUTPUT"
76+
else
77+
echo 'image_name=${{inputs.image_name}}' >> "$GITHUB_OUTPU"
78+
end
7079
- name: Docker meta
7180
id: meta
7281
uses: docker/metadata-action@v4
7382
with:
7483
# list of Docker images to use as base name for tags
7584
images: |
76-
${{ inputs.registry }}/${{ inputs.image_name }}
85+
${{ inputs.registry }}/${{ steps.image_name.outputs.image_name }}
7786
# generate Docker tags based on the following events/attributes
7887
tags: |
7988
type=sha

0 commit comments

Comments
 (0)