mirror of
https://github.com/docker/metadata-action.git
synced 2024-11-22 12:05:41 +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:
parent
3ae5afe041
commit
7040b59aa5
@ -1,5 +1,10 @@
|
||||
# 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)
|
||||
|
||||
* Allow to add custom tags (#24)
|
||||
|
23
__tests__/fixtures/event_push_invalidchars.env
Normal file
23
__tests__/fixtures/event_push_invalidchars.env
Normal 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
|
@ -376,6 +376,35 @@ describe('push', () => {
|
||||
"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);
|
||||
});
|
||||
|
||||
|
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
@ -242,7 +242,7 @@ class Meta {
|
||||
}
|
||||
}
|
||||
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) {
|
||||
version.main = 'edge';
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ export class Meta {
|
||||
version.latest = this.inputs.tagLatest;
|
||||
}
|
||||
} 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) {
|
||||
version.main = 'edge';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user