88 schedule :
99 - cron : ' 0 3 1,15 * *'
1010
11+ env :
12+ REGISTRY_IMAGE : ghcr.io/nukib/misp-modules
13+
1114jobs :
1215 build :
1316 runs-on : ${{ matrix.runner }}
@@ -17,71 +20,103 @@ jobs:
1720 steps :
1821 - name : Checkout
1922 uses : actions/checkout@v4
20- -
21- name : Set up Docker Buildx
23+
24+ - name : Set up Docker Buildx
2225 uses : docker/setup-buildx-action@v3
23- -
24- name : Cache Docker layers
26+
27+ - name : Cache Docker layers
2528 uses : actions/cache@v4
2629 with :
2730 path : /tmp/.buildx-cache
2831 key : ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }}
2932 restore-keys : |
3033 ${{ runner.os }}-${{ runner.arch }}-buildx-
31- -
32- name : Build and export to Docker
34+
35+ - name : Build and export to Docker
3336 uses : docker/build-push-action@v6
3437 with :
3538 context : .
3639 load : true
37- tags : |
38- nukib/misp-modules:latest
39- ghcr.io/nukib/misp-modules:latest
40+ tags : ${{ env.REGISTRY_IMAGE }}
4041 cache-from : type=local,src=/tmp/.buildx-cache/amd64
4142 cache-to : type=local,dest=/tmp/.buildx-cache-new/amd64,mode=max
42- -
43- name : Show image details
43+
44+ - name : Show image details
4445 run : |
45- docker image inspect nukib/misp-modules:latest
46- docker image history nukib/misp-modules:latest
47- -
48- name : Test
46+ docker image inspect ${{ env.REGISTRY_IMAGE }}
47+ docker image history ${{ env.REGISTRY_IMAGE }}
48+
49+ - name : Test
4950 run : |
50- docker run --name misp-modules --rm -p 127.0.0.1:6666:6666 nukib/misp-modules:latest &
51+ docker run --name misp-modules --rm -p 127.0.0.1:6666:6666 ${{ env.REGISTRY_IMAGE }} &
5152 sleep 5 # Wait until container is ready
5253 curl --fail http://localhost:6666/modules | jq
5354 docker stop misp-modules
54- -
55- # Temp fix
56- # https://github.com/docker/build-push-action/issues/252
57- # https://github.com/moby/buildkit/issues/1896
58- name : Move cache
55+
56+ # Temp fix
57+ # https://github.com/docker/build-push-action/issues/252
58+ # https://github.com/moby/buildkit/issues/1896
59+ - name : Move cache
5960 run : |
6061 rm -rf /tmp/.buildx-cache
6162 mv /tmp/.buildx-cache-new /tmp/.buildx-cache
6263 du -sh /tmp/.buildx-cache
63- -
64- name : Login to GitHub Container Registry
64+
65+ - name : Login to GitHub Container Registry
6566 if : github.event_name != 'pull_request'
6667 uses : docker/login-action@v3
6768 with :
6869 registry : ghcr.io
6970 username : ${{ github.repository_owner }}
7071 password : ${{ secrets.GITHUB_TOKEN }}
71- -
72- name : Login to DockerHub
72+
73+ - name : Push by digest
7374 if : github.event_name != 'pull_request'
74- uses : docker/login-action@v3
75+ id : build
76+ uses : docker/build-push-action@v6
7577 with :
76- username : nukib
77- password : ${{ secrets.DOCKERHUB_TOKEN }}
78- -
79- name : Push
78+ tags : ${{ env.REGISTRY_IMAGE }}
79+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
80+
81+ - name : Export digest
8082 if : github.event_name != 'pull_request'
81- uses : docker/build-push-action@v6
83+ run : |
84+ mkdir -p ${{ runner.temp }}/digests
85+ digest="${{ steps.build.outputs.digest }}"
86+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
87+
88+ - name : Upload digest
89+ if : github.event_name != 'pull_request'
90+ uses : actions/upload-artifact@v4
8291 with :
83- push : true
84- tags : |
85- nukib/misp-modules:latest
86- ghcr.io/nukib/misp-modules:latest
87-
92+ name : digests-${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
93+ path : ${{ runner.temp }}/digests/*
94+ if-no-files-found : error
95+ retention-days : 1
96+
97+ push :
98+ runs-on : ubuntu-latest
99+ needs : build
100+ if : github.event_name != 'pull_request'
101+ steps :
102+ - name : Download digests
103+ uses : actions/download-artifact@v4
104+ with :
105+ path : ${{ runner.temp }}/digests
106+ pattern : digests-*
107+ merge-multiple : true
108+
109+ - name : Set up Docker Buildx
110+ uses : docker/setup-buildx-action@v3
111+
112+ - name : Login to GitHub Container Registry
113+ uses : docker/login-action@v3
114+ with :
115+ registry : ghcr.io
116+ username : ${{ github.repository_owner }}
117+ password : ${{ secrets.GITHUB_TOKEN }}
118+
119+ - name : Create manifest list and push
120+ working-directory : ${{ runner.temp }}/digests
121+ run : |
122+ docker buildx imagetools create --tag ${{ env.REGISTRY_IMAGE }}:latest $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
0 commit comments