-
Notifications
You must be signed in to change notification settings - Fork 110
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
Question: list vs YAML array for inputs #88
Comments
This is a limitation with the GitHub Actions toolkit itself yes (actions/toolkit#184).
The separator used by the metadata action for
We could output labels, tags and other info using a JSON representation with a new output for this purpose: {
"tags": [
"name/app:1.2.3",
"name/app:1.2",
"name/app:sha-90dd603",
"name/app:latest"
],
"labels": {
"org.opencontainers.image.title": "Hello-World",
"org.opencontainers.image.description": "This your first repo!",
"org.opencontainers.image.url": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.source": "https://github.com/octocat/Hello-World",
"org.opencontainers.image.version": "1.2.3",
"org.opencontainers.image.created": "2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision": "90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses": "MIT"
}
} This way you could use the - name: Prepare image metadata
uses: docker/metadata-action@v3
id: meta
with:
images: repo/app
- name: Build and push docker image
uses: docker/build-push-action@v2
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} |
Thank you for a quick response on that!
I would definitely appreciate if you can add json format output so I can throw away this intermediate step |
@tpolekhin Ok thanks for your feedback. I move this issue to the metadata repo. |
@tpolekhin You can try with |
@crazy-max Works perfectly! Thanks! Are you planning to release a new version? |
@tpolekhin Yes in few minutes |
Hello!
I was wondering why use multi-line string
list
instead of YAML array for inputs?Maybe it's a technical limitation and it's okay if so I just wanted to check.
I'm trying to pass build args to the docker build with meta information and having difficulties because of this
list
type.https://github.com/docker/metadata-action provides an easy way to inject meta labels for the container,
exporting a
list
of OCI labels that you can then use forlabels:
input. I guess they used alist
type for their output to match this action input type.I'm trying to reuse some of them as build args to also inject this information into the app binary, but it doesn't work because
steps.meta.outputs.labels
is not an array. I was looking around for a conversion function or tool that would help me to get this values out oflabels
, but couldn't find anything.I think it would be more convenient to work with JSON/YAML Arrays, just because there's a lot more supported tooling and operations than for just a list of strings.
Curious to get your opinion on this
The text was updated successfully, but these errors were encountered: