Comments (6)
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.
This is a limitation with the GitHub Actions toolkit itself yes (actions/toolkit#184).
I guess they used a
list
type for their output to match this action input type.
The separator used by the metadata action for tags
or labels
output is lf (\n
).
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.
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 fromJSON
function expression to handle that:
- 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'] }}
from metadata-action.
Thank you for a quick response on that!
Currently I use workaround, pretty similar to what you proposed actually :)
- name: Extract meta image labels
id: extract
run: echo ::set-output name=labels::$(jq -r -c '.target."docker-metadata-action".labels' ${{ steps.meta.outputs.bake-file }})
- name: Build and push operator image
uses: docker/build-push-action@v2
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDTIME=${{ fromJSON(steps.extract.outputs.labels)['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.extract.outputs.labels)['org.opencontainers.image.version'] }}
REVISION=${{ fromJSON(steps.extract.outputs.labels)['org.opencontainers.image.revision'] }}
I would definitely appreciate if you can add json format output so I can throw away this intermediate step
from metadata-action.
@tpolekhin Ok thanks for your feedback. I move this issue to the metadata repo.
from metadata-action.
@tpolekhin You can try with docker/metadata-action@master
.
from metadata-action.
@crazy-max Works perfectly! Thanks!
https://github.com/tpolekhin/actions-playground/runs/2650265161
Are you planning to release a new version?
I'm a little concerned to use @master
in the real pipeline
from metadata-action.
@tpolekhin Yes in few minutes
from metadata-action.
Related Issues (20)
- is it possible to have generic pre-release tags? HOT 5
- Feature request: git submodule context HOT 1
- Unable to verify the first certificate HOT 4
- latest tag README instructions cause errors HOT 4
- Unexpected tag is created for type=match HOT 1
- `latest` tag in auto-mode is applied to older major versions HOT 2
- Feature request and discussion: support of annotations HOT 4
- Metadata action does not properly distinguish bake matrix targets HOT 1
- IP address is not permitted to access this resource HOT 3
- Disable `main` tag when `latest` is enabled HOT 2
- Secrets exposed in some action output HOT 1
- org.opencontainers.image.source is missing from the annotations section of the manifests HOT 2
- Custom annotations HOT 1
- Action fails: Cannot find detached HEAD ref in "grafted, HEAD, tag: x.x.x" HOT 10
- Warning: No Docker image version has been generated. Check tags input. HOT 1
- Missing latest tag on type=match HOT 1
- Images cannot be empty as documentation suggests HOT 1
- v5.5.0 Broke docker/bake-action with docker-metadata-action HOT 4
- #370 breaks GitHub Actions build example HOT 3
- semver tag : allow outputing build information (part after plus) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metadata-action.