-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (60 loc) · 1.95 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# On push: build latest images
name: CI
on:
push:
branches: [ master ]
tags:
- "v?[0-9]+.[0-9]+.[0-9]+*"
pull_request:
jobs:
build-pypy-dicomweb:
name: Build pypx-DICOMweb
runs-on: ubuntu-22.04
steps:
- name: Decide image tags
id: info
shell: python
run: |
import os
import itertools
registries = ['docker.io', 'ghcr.io']
repos = ['fnndsc/pypx-dicomweb']
if '${{ github.ref_type }}' == 'branch':
tags = ['latest']
elif '${{ github.ref_type }}' == 'tag':
tags = ['latest', '${{ github.ref_name }}']
else:
tags = []
def join_tag(t):
registry, repo, tag = t
return f'{registry}/{repo}:{tag}'
product = itertools.product(registries, repos, tags)
tags_csv = ','.join(map(join_tag, product))
push = 'true' if tags_csv else 'false'
with open(os.environ['GITHUB_OUTPUT'], 'a') as out:
out.write(f'tags={tags_csv}\n')
out.write(f'push={push}\n')
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name == 'push' || github.event_name == 'release'
id: dockerhub_login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
if: github.event_name == 'push' || github.event_name == 'release'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
id: docker_build
with:
file: ./pypx-DICOMweb.Dockerfile
tags: ${{ steps.info.outputs.tags }}
push: ${{ steps.info.outputs.push }}
cache-from: type=gha
cache-to: type=gha,mode=max