Skip to content

Commit 25beafa

Browse files
authored
Fix handling metadata with single quotes (#90)
1 parent 99d5e1a commit 25beafa

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

action.yml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: 'Docker build and push'
2-
description: 'Simple Docker build and push action'
1+
name: "Docker build and push"
2+
description: "Simple Docker build and push action"
33
44
branding:
5-
icon: 'box'
6-
color: 'white'
5+
icon: "box"
6+
color: "white"
77
inputs:
88
allow:
99
description: "List of extra privileged entitlement (e.g., network.host,security.insecure)"
@@ -15,60 +15,60 @@ inputs:
1515
description: "List of additional build contexts (e.g., name=path)"
1616
required: false
1717
buildkitd-flags:
18-
description: 'BuildKit daemon flags'
19-
default: '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host'
18+
description: "BuildKit daemon flags"
19+
default: "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host"
2020
required: false
2121
driver-opts:
22-
description: 'List of additional driver-specific options. (eg. image=moby/buildkit:master)'
22+
description: "List of additional driver-specific options. (eg. image=moby/buildkit:master)"
2323
required: false
2424
default: image=public.ecr.aws/vend/moby/buildkit:buildx-stable-1
2525
binfmt-image:
26-
description: 'Binfmt image'
26+
description: "Binfmt image"
2727
required: false
2828
default: public.ecr.aws/eks-distro-build-tooling/binfmt-misc:qemu-v7.0.0
2929
workdir:
30-
description: 'Working directory'
30+
description: "Working directory"
3131
required: false
32-
default: './'
32+
default: "./"
3333
file:
34-
description: 'Dockerfile name'
34+
description: "Dockerfile name"
3535
required: false
36-
default: 'Dockerfile'
36+
default: "Dockerfile"
3737
build-args:
3838
description: "List of build-time variables"
3939
required: false
4040
organization:
41-
description: 'Organization'
41+
description: "Organization"
4242
required: true
4343
repository:
44-
description: 'Repository'
44+
description: "Repository"
4545
required: true
4646
registry:
47-
description: 'Docker registry'
47+
description: "Docker registry"
4848
required: true
4949
target:
5050
description: "Sets the target stage to build"
5151
required: false
52-
default: ''
52+
default: ""
5353
platforms:
5454
description: "List of target platforms for build (e.g. linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,etc)"
5555
required: false
56-
default: 'linux/amd64'
56+
default: "linux/amd64"
5757
provenance:
5858
description: "Generate provenance attestation for the build"
5959
required: false
6060
image_name:
6161
description: "Image name (excluding registry). Defaults to {{$organization/$repository}}."
6262
required: false
63-
default: ''
63+
default: ""
6464
login:
65-
description: 'Docker login'
65+
description: "Docker login"
6666
required: false
67-
default: ''
67+
default: ""
6868
password:
69-
description: 'Docker password'
69+
description: "Docker password"
7070
required: false
71-
default: ''
71+
default: ""
7272
cache-from:
7373
description: "List of external cache sources for buildx (e.g., user/app:cache, type=local,src=path/to/dir)"
7474
required: false
@@ -159,11 +159,11 @@ runs:
159159
labels: |
160160
org.opencontainers.image.source=https://github.com/${{ inputs.organization }}/${{ inputs.repository }}
161161
162-
- name: 'Install jq 1.6'
162+
- name: "Install jq 1.6"
163163
uses: dcarbone/[email protected]
164164
with:
165165
version: 1.6
166-
force: 'true'
166+
force: "true"
167167

168168
# here we set the first tag in the output as the output of this step
169169
# this order is determined by the priority, we set the sha as 1001, as that is 1 above the defaults
@@ -195,7 +195,7 @@ runs:
195195
uses: docker/setup-buildx-action@v3
196196
with:
197197
endpoint: buildx-context
198-
buildkitd-flags: "${{ inputs.debug == 'true' && '--debug' || '' }} ${{ inputs.buildkitd-flags }}"
198+
buildkitd-flags: "${{ inputs.debug == 'true' && '--debug' || '' }} ${{ inputs.buildkitd-flags }}"
199199
driver-opts: "${{ inputs.driver-opts }}"
200200

201201
- name: Login
@@ -206,7 +206,6 @@ runs:
206206
username: ${{ inputs.login }}
207207
password: ${{ inputs.password }}
208208

209-
210209
- name: Build and push Docker images
211210
# Do not update to >=v6 untill the issue would be solved
212211
# https://github.com/docker/build-push-action/issues/1167
@@ -236,17 +235,22 @@ runs:
236235
- name: Get Metadata
237236
id: get-metadata
238237
shell: bash
238+
env:
239+
METADATA: ${{ toJSON(steps.docker-build-push-action.outputs.metadata) }}
239240
run: |
240-
metadata=$(echo '${{ steps.docker-build-push-action.outputs.metadata }}' | jq -c)
241-
echo "metadata=$metadata" >> $GITHUB_OUTPUT
241+
{
242+
echo "metadata<<EOF"
243+
echo "$METADATA"
244+
echo "EOF"
245+
} >> $GITHUB_OUTPUT
242246
echo "## Docker Image Metadata" >> $GITHUB_STEP_SUMMARY
243247
echo '```json' >> $GITHUB_STEP_SUMMARY
244-
echo "$metadata" | jq >> $GITHUB_STEP_SUMMARY
248+
echo "$METADATA" | jq >> $GITHUB_STEP_SUMMARY
245249
echo '```' >> $GITHUB_STEP_SUMMARY
246250
247251
- name: Docker Inspect
248252
id: inspect
249-
if: ${{ inputs.inspect }} == 'true'
253+
if: ${{ inputs.inspect }} == 'true'
250254
shell: bash
251255
run: |
252256
docker pull "${{ inputs.registry }}/${{ steps.image_name.outputs.image_name }}:${{ steps.tag.outputs.output }}"

0 commit comments

Comments
 (0)