Skip to content

Add a {{ license }} global expression #585

@polarathene

Description

@polarathene

Description

`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`

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:

metadata-action/src/meta.ts

Lines 540 to 553 in ed95091

private getOCIAnnotationsWithCustoms(extra: string[]): Array<string> {
const res: Array<string> = [
`org.opencontainers.image.title=${this.repo.name || ''}`,
`org.opencontainers.image.description=${this.repo.description || ''}`,
`org.opencontainers.image.url=${this.repo.html_url || ''}`,
`org.opencontainers.image.source=${this.repo.html_url || ''}`,
`org.opencontainers.image.version=${this.version.main || ''}`,
`org.opencontainers.image.created=${this.date.toISOString()}`,
`org.opencontainers.image.revision=${this.context.sha || ''}`,
`org.opencontainers.image.licenses=${this.repo.license?.spdx_id || ''}`
];
extra.forEach(label => {
res.push(this.setGlobalExp(label));
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions