3
0
Fork 0
mirror of https://gitea.com/docker/metadata-action.git synced 2024-11-25 13:39:33 +01:00

Replace forbidden chars derived from branch name (#29)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-12-08 00:01:39 +01:00 committed by GitHub
parent 3ae5afe041
commit 7040b59aa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 2 deletions

View file

@ -1,5 +1,10 @@
# Changelog # Changelog
## 1.9.1 (2020/12/07)
* Replace forbidden chars derived from branch name (#30)
* Bump semver from 7.3.2 to 7.3.4 (#26)
## 1.9.0 (2020/12/04) ## 1.9.0 (2020/12/04)
* Allow to add custom tags (#24) * Allow to add custom tags (#24)

View file

@ -0,0 +1,23 @@
GITHUB_ACTION=crazy-maxghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTOR=crazy-max
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_89a016e8-e5b7-4039-a67e-c8da08f87a0c
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_89a016e8-e5b7-4039-a67e-c8da08f87a0c
GITHUB_REF="refs/heads/my/feature#1245"
GITHUB_REPOSITORY=crazy-max/test-docker-action
GITHUB_REPOSITORY_OWNER=crazy-max
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=325957516
GITHUB_RUN_NUMBER=1
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
GITHUB_WORKFLOW=event
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action

View file

@ -376,6 +376,35 @@ describe('push', () => {
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
] ]
], ],
[
'event_push_invalidchars.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tagSha: true,
tagEdge: true,
} as Inputs,
{
main: 'my-feature-1245',
partial: [],
latest: false
} as Version,
[
'org/app:my-feature-1245',
'org/app:sha-90dd603',
'ghcr.io/user/app:my-feature-1245',
'ghcr.io/user/app:sha-90dd603'
],
[
"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=my-feature-1245",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
],
])('given %p event ', tagsLabelsTest); ])('given %p event ', tagsLabelsTest);
}); });

2
dist/index.js generated vendored
View file

@ -242,7 +242,7 @@ class Meta {
} }
} }
else if (/^refs\/heads\//.test(this.context.ref)) { else if (/^refs\/heads\//.test(this.context.ref)) {
version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-'); version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.main) { if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.main) {
version.main = 'edge'; version.main = 'edge';
} }

View file

@ -83,7 +83,7 @@ export class Meta {
version.latest = this.inputs.tagLatest; version.latest = this.inputs.tagLatest;
} }
} else if (/^refs\/heads\//.test(this.context.ref)) { } else if (/^refs\/heads\//.test(this.context.ref)) {
version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-'); version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.main) { if (this.inputs.tagEdge && this.inputs.tagEdgeBranch === version.main) {
version.main = 'edge'; version.main = 'edge';
} }