|
run: | |
|
import os |
|
import itertools |
|
|
|
def join_tag(t): |
|
registry, repo, tag = t |
|
return f'{registry}/{repo}:{tag}'.lower() |
|
|
|
registries = ['docker.io', 'ghcr.io'] |
|
repos = ['${{ github.repository }}'] |
|
if '${{ github.ref_type }}' == 'branch': |
|
tags = ['latest'] |
|
elif '${{ github.ref_type }}' == 'tag': |
|
tag = '${{ github.ref_name }}' |
|
version = tag[1:] if tag.startswith('v') else tag |
|
tags = ['latest', version] |
|
else: |
|
tags = [] |
|
|
|
if '${{ github.ref_type }}' == 'tag': |
|
local_tag = join_tag(('ghcr.io', '${{ github.repository }}', version)) |
|
else: |
|
local_tag = join_tag(('localhost', '${{ github.repository }}', 'latest')) |
|
|
|
product = itertools.product(registries, repos, tags) |
|
tags_csv = ','.join(map(join_tag, product)) |
|
outputs = { |
|
'tags_csv' : tags_csv, |
|
'push' : 'true' if tags_csv else 'false', |
|
'local_tag': local_tag |
|
} |
|
with open(os.environ['GITHUB_OUTPUT'], 'a') as out: |
|
for k, v in outputs.items(): |
|
out.write(f'{k}={v}\n') |
This can be replaced with https://github.com/docker/metadata-action
python-chrisapp-template/.github/workflows/ci.yml
Lines 53 to 86 in 1e9e879
This can be replaced with https://github.com/docker/metadata-action