Skip to content

Commit

Permalink
Don't apply tag if no tag-pattern is set
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Dec 28, 2020
1 parent d153c68 commit 3036cf1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# v2

- Fixed tag applied to images on tag event while having not set any tag-pattern

# v1

- initial version
4 changes: 2 additions & 2 deletions compute_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

ref = os.getenv("GITHUB_REF").split("/", 2)[-1]
is_tag = os.getenv("GITHUB_REF").startswith("refs/tags/")
if is_tag:
exp = os.getenv("TAG_PATTERN", "")
exp = os.getenv("TAG_PATTERN", "")
if is_tag and exp:
# convert from perl syntax (/pattern/) to python one
if perl_re.match(exp):
exp = perl_re.match(exp).groups()[-1]
Expand Down
12 changes: 12 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,15 @@ def test_tag_patterns(github_env, repo_name, tag_pattern, tag, expected):
assert len(res) == 2
assert f"{repo_name}:{expected}" in res
assert f"ghcr.io/{repo_name}:{expected}" in res


def test_tag_without_tag_pattern(github_env, repo_name):
res = launch_and_retrieve(
**get_env(
github_env=github_env,
repo_name=repo_name,
image_path="openzim/zimfarm-task-worker",
is_tag="uploader-v1.1.1",
)
)
assert len(res) == 0

0 comments on commit 3036cf1

Please sign in to comment.