docker / docker/metadata-action

Add a `{{ license }}` global expression

Open
#585 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement status/triage
Dominant language
TypeScript
Stars
1.1k
Forks
160
Avg merge
4d 17h
Merged PRs (30d)
12

Description

Description

https://github.com/docker/metadata-action/blob/ed95091677497158a9ff38b314264cd965388d5e/src/meta.ts#L549

The equivalent expression in Github Actions is invalid as ? syntax is not supported.

The labels/annotations entry would instead look like this:

org.opencontainers.image.licenses=${{ github.event.repository.license && github.event.repository.license.spdx_id }}

This is effectively the only label/annotation that can't easily / tersely be expressed, so the {{ license }} handlebars global expression would be convenient.


There isn't much reason to add this other than choosing to be more explicit about the values (I documented such here) as the defaults aren't publicly documented by this action, one must look them up via source:

https://github.com/docker/metadata-action/blob/ed95091677497158a9ff38b314264cd965388d5e/src/meta.ts#L540-L553

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/meta.ts at the linked metadata defaults around line 549, then trace how global expressions are defined and exposed to labels or annotations. The work is done when a {{ license }} expression can provide the repository license SPDX identifier in the documented YAML entry without relying on unsupported ? syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd, devops
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.