77
88
99env :
10- REGISTRY : docker.io
11- IMAGE_NAME : helmuthva/oe-python-template-example
10+ DOCKER_IO_REGISTRY : docker.io
11+ DOCKER_IO_IMAGE_NAME_ALL : helmuthva/oe-python-template-example
12+ DOCKER_IO_IMAGE_NAME_SLIM : helmuthva/oe-python-template-example-slim
1213
1314
1415jobs :
@@ -52,14 +53,14 @@ jobs:
5253 password : ${{ secrets.GITHUB_TOKEN }}
5354
5455
55- - name : Extract metadata (tags, labels) for Docker
56- id : meta
56+ - name : (all target): Extract metadata (tags, labels) for Docker
57+ id : meta-all
5758 uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
5859 with :
5960
6061
6162 images : |
62- ${{ env.IMAGE_NAME }}
63+ ${{ env.DOCKER_IO_IMAGE_NAME_ALL }}
6364 ghcr.io/${{ github.repository }}
6465
6566
@@ -73,25 +74,71 @@ jobs:
7374 type=semver,pattern={{major}}
7475
7576
77+ - name : (slim target): Extract metadata (tags, labels) for Docker
78+ id : meta-slim
79+ uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
80+ with :
81+
82+
83+ images : |
84+ ${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}
85+ ghcr.io/${{ github.repository }}-slim
86+
87+
88+
89+ tags : |
90+ # set latest tag for releases
91+ type=raw,value=latest
92+ # set semver tags from git tags (v1.2.3 -> 1.2.3, 1.2, 1)
93+ type=semver,pattern={{version}}
94+ type=semver,pattern={{major}}.{{minor}}
95+ type=semver,pattern={{major}}
96+
97+
7698
77- - name : Build and push Docker image
78- id : push
99+ - name : (all target): Build and push Docker image
100+ id : build-and- push-all
79101 uses : docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
80102 with :
81103 context : .
82104 file : ./Dockerfile
105+ target : all
83106 platforms : linux/amd64,linux/arm64
84107 push : true
85- tags : ${{ steps.meta.outputs.tags }}
86- labels : ${{ steps.meta.outputs.labels }}
108+ tags : ${{ steps.meta-all .outputs.tags }}
109+ labels : ${{ steps.meta-all .outputs.labels }}
87110
88111
89112
113+ - name : (slim target):Build and push Docker image
114+ id : build-and-push-slim
115+ uses : docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
116+ with :
117+ context : .
118+ file : ./Dockerfile
119+ target : slim
120+ platforms : linux/amd64,linux/arm64
121+ push : true
122+ tags : ${{ steps.meta-slim.outputs.tags }}
123+ labels : ${{ steps.meta-slim.outputs.labels }}
124+
125+
126+
127+
128+
129+ - name : (all target): Generate artifact attestation
130+ uses : actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
131+ with :
132+ subject-name : ${{ env.DOCKER_IO_REGISTRY }}/${{ env.DOCKER_IO_IMAGE_NAME_ALL }}
133+ subject-digest : ${{ steps.build-and-push-all.outputs.digest }}
134+ push-to-registry : true
135+
136+
90137
91138
92- - name : Generate artifact attestation
139+ - name : (slim target): Generate artifact attestation
93140 uses : actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
94141 with :
95- subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
96- subject-digest : ${{ steps.push.outputs.digest }}
142+ subject-name : ${{ env.DOCKER_IO_REGISTRY }}/${{ env.DOCKER_IO_IMAGE_NAME_SLIM }}
143+ subject-digest : ${{ steps.build-and- push-slim .outputs.digest }}
97144 push-to-registry : true
0 commit comments