@@ -9,12 +9,16 @@ permissions:
99 contents : read
1010
1111jobs :
12- build :
12+ jar- build :
1313 runs-on : ubuntu-latest
14+
1415 permissions :
1516 contents : read
1617 packages : write
1718
19+ outputs :
20+ version : ${{steps.build.outputs.version}}
21+
1822 steps :
1923 - name : Checkout
2024 uses : actions/checkout@v4
@@ -37,195 +41,32 @@ jobs:
3741 export VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
3842 echo "version=${VERSION}" >> $GITHUB_OUTPUT
3943
40- # docker images
41-
42- - name : Set up QEMU
43- uses : docker/setup-qemu-action@v3
44-
45- - name : Set up Docker Buildx
46- id : buildx
47- uses : docker/setup-buildx-action@v3
48-
49- - name : Cache Docker layers
50- uses : actions/cache@v4
51- with :
52- path : /tmp/.buildx-cache
53- key : ${{ runner.os }}-buildx-${{ github.sha }}
54- restore-keys : |
55- ${{ runner.os }}-buildx-
56-
57- # Build multi platform images and loading them at the same time is not possible with default container runtime : https://github.com/docker/buildx/issues/59
58- # So let's use containerd instead as it supports this option
59- # Also containerd is one of the option to allow preserving provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
60- - name : Setup docker with containerd
61- uses : crazy-max/ghaction-setup-docker@v3
62- with :
63- daemon-config : |
64- {
65- "features": {
66- "containerd-snapshotter": true
67- }
68- }
69-
70- - name : Build docker image
71- id : docker_build
72- uses : docker/build-push-action@v5
73- with :
74- builder : ${{ steps.buildx.outputs.name }}
75- context : api
76- platforms : linux/amd64,linux/arm64
77- provenance : mode=min
78- sbom : true
79- push : false
80- load : true
81- tags : |
82- kafka-ui:temp
83- build-args : |
84- JAR_FILE=api-${{ steps.build.outputs.version }}.jar
85- cache-from : type=local,src=/tmp/.buildx-cache
86- cache-to : type=local,dest=/tmp/.buildx-cache
87-
88- - name : Dump docker image
89- run : |
90- docker image save kafka-ui:temp > /tmp/image.tar
91-
92- - name : Upload docker image
44+ - name : Upload jar
9345 uses : actions/upload-artifact@v4
9446 with :
95- name : image
96- path : /tmp/image.tar
97- retention-days : 1
47+ name : kafbat-ui-${{ steps.build.outputs.version }}
48+ path : api/target/api-${{ steps.build.outputs.version }}.jar
49+ retention-days : 7
9850
99- deploy-ghcr :
100- runs-on : ubuntu-latest
101- needs : build
51+ docker-build :
52+ needs : jar-build
10253 permissions :
54+ contents : read
10355 packages : write
104-
105- steps :
106- - name : Download docker image
107- uses : actions/download-artifact@v4
108- with :
109- name : image
110- path : /tmp
111-
112- # setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
113- - name : Setup docker with containerd
114- uses : crazy-max/ghaction-setup-docker@v3
115- with :
116- daemon-config : |
117- {
118- "features": {
119- "containerd-snapshotter": true
120- }
121- }
122-
123- - name : Load docker image into daemon
124- run : |
125- docker load --input /tmp/image.tar
126-
127- - name : Login to GitHub Container Registry
128- uses : docker/login-action@v3
129- with :
130- registry : ghcr.io
131- username : " ${{ github.actor }}"
132- password : ${{ secrets.GITHUB_TOKEN }}
133-
134- - name : Push images to GHCR
135- run : |
136- docker tag kafka-ui:temp ghcr.io/kafbat/kafka-ui:main
137- docker tag kafka-ui:temp ghcr.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
138- docker push ghcr.io/kafbat/kafka-ui:main
139- docker push ghcr.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
140-
141- deploy-dockerhub :
142- runs-on : ubuntu-latest
143- needs : build
144-
145- steps :
146- - name : Download docker image
147- uses : actions/download-artifact@v4
148- with :
149- name : image
150- path : /tmp
151-
152- # setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
153- - name : Setup docker with containerd
154- uses : crazy-max/ghaction-setup-docker@v3
155- with :
156- daemon-config : |
157- {
158- "features": {
159- "containerd-snapshotter": true
160- }
161- }
162-
163- - name : Load docker image into daemon
164- run : |
165- docker load --input /tmp/image.tar
166-
167- - name : Login to Dockerhub
168- uses : docker/login-action@v3
169- with :
170- username : ${{ secrets.DOCKERHUB_USERNAME }}
171- password : ${{ secrets.DOCKERHUB_TOKEN }}
172-
173- - name : Push images to dockerhub
174- run : |
175- docker tag kafka-ui:temp docker.io/kafbat/kafka-ui:main
176- docker tag kafka-ui:temp docker.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
177- docker push docker.io/kafbat/kafka-ui:main
178- docker push docker.io/kafbat/kafka-ui:${{ needs.build.outputs.version }}
179-
180-
181- deploy-ecr :
182- runs-on : ubuntu-latest
183- needs : build
56+ uses : ./.github/workflows/docker_build.yml
57+ secrets : inherit
58+ with :
59+ sha : ${{ github.sha }}
60+ version : ${{ needs.jar-build.outputs.version }}
61+
62+ docker-deploy :
63+ needs : [jar-build, docker-build]
18464 permissions :
18565 contents : read # To read secrets
18666 id-token : write # This is required for requesting the JWT
187-
188- steps :
189- - name : Download docker image
190- uses : actions/download-artifact@v4
191- with :
192- name : image
193- path : /tmp
194-
195- # setup containerd to preserve provenance attestations :https://docs.docker.com/build/attestations/#creating-attestations
196- - name : Setup docker with containerd
197- uses : crazy-max/ghaction-setup-docker@v3
198- with :
199- daemon-config : |
200- {
201- "features": {
202- "containerd-snapshotter": true
203- }
204- }
205-
206- - name : Load docker image into daemon
207- run : |
208- docker load --input /tmp/image.tar
209-
210- - name : Configure AWS credentials
211- uses : aws-actions/configure-aws-credentials@v4
212- with :
213- aws-region : us-east-1 # This region only for public ECR
214- role-to-assume : ${{ secrets.AWS_ROLE }}
215-
216- - name : Login to public ECR
217- id : login-ecr-public
218- uses : aws-actions/amazon-ecr-login@v2
219- with :
220- registry-type : public
221-
222- - name : Push to ECR
223- env :
224- REGISTRY : ${{steps.login-ecr-public.outputs.registry }}
225- REGISTRY_ALIAS : j4u0y1h1
226- REPOSITORY : kafka-ui
227- run : |
228- docker tag kafka-ui:temp $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:main
229- docker tag kafka-ui:temp $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:${{ needs.build.outputs.version }}
230- docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:main
231- docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:${{ needs.build.outputs.version }}
67+ packages : write
68+ uses : ./.github/workflows/docker_publish.yml
69+ secrets : inherit
70+ with :
71+ version : ${{ needs.jar-build.outputs.version }}
72+ generic_tag : main
0 commit comments