77 tags :
88 - " v*"
99
10+ # Necessario per pushare su GHCR
11+ permissions :
12+ contents : read
13+ packages : write
14+
1015env :
1116 REGISTRY : ghcr.io
12- IMAGE_NAME : ${{ github.repository }}
1317
1418jobs :
15- test :
19+ # Build quando pushi su branch (es. master)
20+ build_branch :
21+ if : github.ref_type == 'branch'
22+ runs-on : ubuntu-latest
23+
24+ concurrency :
25+ group : ${{ github.workflow }}-${{ github.ref }}
26+ cancel-in-progress : true
27+
28+ strategy :
29+ fail-fast : false
30+ matrix :
31+ include :
32+ - dockerfile : ./compose/local/django/Dockerfile
33+ context : ./compose/local/django
34+ image : ghcr.io/ldo-cert/orochi_django
35+ - dockerfile : ./compose/local/dask/Dockerfile
36+ context : ./compose/local/dask
37+ image : ghcr.io/ldo-cert/orochi_worker
38+ - dockerfile : ./compose/local/nginx/Dockerfile
39+ context : ./compose/local/nginx
40+ image : ghcr.io/ldo-cert/orochi_nginx
41+
42+ steps :
43+ - name : Checkout code
44+ uses : actions/checkout@v4
45+
46+ - name : Set up QEMU
47+ uses : docker/setup-qemu-action@v3
48+
49+ - name : Set up Docker Buildx
50+ uses : docker/setup-buildx-action@v3
51+
52+ - name : Log in to GHCR
53+ uses : docker/login-action@v3
54+ with :
55+ registry : ${{ env.REGISTRY }}
56+ username : ${{ github.actor }}
57+ password : ${{ secrets.GITHUB_TOKEN }}
58+
59+ - name : Build and push (branch) 🚀
60+ uses : docker/build-push-action@v5
61+ with :
62+ context : ${{ matrix.context }}
63+ file : ${{ matrix.dockerfile }}
64+ platforms : linux/amd64,linux/arm64
65+ push : ${{ github.event_name != 'pull_request' }}
66+ cache-from : type=gha
67+ cache-to : type=gha,mode=max
68+ tags : |
69+ ${{ matrix.image }}:latest
70+ ${{ matrix.image }}:${{ github.sha }}
71+
72+ # Build quando pushi un tag (v*)
73+ build_tag :
74+ if : github.ref_type == 'tag'
1675 runs-on : ubuntu-latest
1776
1877 concurrency :
@@ -24,14 +83,14 @@ jobs:
2483 matrix :
2584 include :
2685 - dockerfile : ./compose/local/django/Dockerfile
27- context : ./compose/local/django
28- image : ghcr.io/ldo-cert/orochi_django
86+ context : ./compose/local/django
87+ image : ghcr.io/ldo-cert/orochi_django
2988 - dockerfile : ./compose/local/dask/Dockerfile
30- context : ./compose/local/dask
31- image : ghcr.io/ldo-cert/orochi_worker
89+ context : ./compose/local/dask
90+ image : ghcr.io/ldo-cert/orochi_worker
3291 - dockerfile : ./compose/local/nginx/Dockerfile
33- context : ./compose/local/nginx
34- image : ghcr.io/ldo-cert/orochi_nginx
92+ context : ./compose/local/nginx
93+ image : ghcr.io/ldo-cert/orochi_nginx
3594
3695 steps :
3796 - name : Checkout code
@@ -43,22 +102,24 @@ jobs:
43102 - name : Set up Docker Buildx
44103 uses : docker/setup-buildx-action@v3
45104
46- - name : Log in to the Container registry
105+ - name : Log in to GHCR
47106 uses : docker/login-action@v3
48107 with :
49108 registry : ${{ env.REGISTRY }}
50109 username : ${{ github.actor }}
51110 password : ${{ secrets.GITHUB_TOKEN }}
52111
53- - name : Build and push (with layer caching) 🚀
112+ - name : Build and push (tagged release) 🏷️
54113 uses : docker/build-push-action@v5
55114 with :
56115 context : ${{ matrix.context }}
57- file : ${{ matrix.dockerfile }}
116+ file : ${{ matrix.dockerfile }}
58117 platforms : linux/amd64,linux/arm64
59118 push : ${{ github.event_name != 'pull_request' }}
60119 cache-from : type=gha
61- cache-to : type=gha,mode=max
120+ cache-to : type=gha,mode=max
121+ # Pubblica anche il tag versione (es. v1.2.3)
62122 tags : |
63123 ${{ matrix.image }}:latest
64124 ${{ matrix.image }}:${{ github.sha }}
125+ ${{ matrix.image }}:${{ github.ref_name }}
0 commit comments