@@ -12,7 +12,8 @@ concurrency:
1212 cancel-in-progress : true
1313
1414jobs :
15- build :
15+ # Step 1: Build alpine-base for each arch
16+ build-base :
1617 # Only run for the default branch
1718 if : github.ref_name == github.event.repository.default_branch
1819 permissions :
3435 with :
3536 fetch-depth : 0
3637 persist-credentials : false
38+ - name : Compute unique hash
39+ id : hash
40+ run : |
41+ CONTENT_HASH=$(make --no-print-directory -s alpine-base-show-tag | tail -1 | sed 's/.*://')
42+ GIT_REV=$(git rev-parse --short HEAD)
43+ HASH="${CONTENT_HASH}-${GIT_REV}"
44+ echo "hash=${HASH}" >> "$GITHUB_OUTPUT"
45+ echo "Alpine-base hash: ${HASH}"
3746 - name : Set up QEMU for cross-arch builds
3847 if : matrix.arch == 'riscv64'
3948 run : |
@@ -46,25 +55,130 @@ jobs:
4655 password : ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
4756 - name : Build and push alpine-base (${{ matrix.arch }})
4857 run : |
49- make V=1 ZARCH=${{ matrix.arch }} LINUXKIT_PKG_TARGET=push pkg/alpine-base
58+ make V=1 ZARCH=${{ matrix.arch }} LINUXKIT_PKG_TARGET=push \
59+ \
60+ LINUXKIT_EXTRA_BUILD_ARGS="--force --hash ${{ steps.hash.outputs.hash }}" \
61+ pkg/alpine-base
62+ outputs :
63+ hash : ${{ steps.hash.outputs.hash }}
64+
65+ # Step 2: Create multi-arch manifest for alpine-base
66+ manifest-base :
67+ needs : build-base
68+ runs-on : zededa-ubuntu-2204
69+ if : github.ref_name == github.event.repository.default_branch
70+ permissions :
71+ contents : read
5072
51- manifest :
52- needs : build
73+ steps :
74+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
75+ with :
76+ fetch-depth : 0
77+ persist-credentials : false
78+ - name : Login to Docker Hub
79+ uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
80+ with :
81+ username : ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }}
82+ password : ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
83+ - name : Create multi-arch manifest for alpine-base
84+ run : |
85+ echo "Creating manifest for alpine-base: ${{ needs.build-base.outputs.hash }}"
86+ make V=1 LINUXKIT_PKG_TARGET=manifest \
87+ \
88+ LINUXKIT_EXTRA_BUILD_ARGS="--hash ${{ needs.build-base.outputs.hash }}" \
89+ pkg/alpine-base
90+
91+ # Step 3: Commit updated alpine-base hash to master
92+ commit-hash :
93+ needs : [build-base, manifest-base]
94+ runs-on : zededa-ubuntu-2204
95+ if : github.ref_name == github.event.repository.default_branch
96+ permissions :
97+ contents : write
98+
99+ steps :
100+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
101+ with :
102+ fetch-depth : 0
103+ - name : Update alpine Dockerfile and commit
104+ run : |
105+ NEW_HASH="${{ needs.build-base.outputs.hash }}"
106+ echo "Updating eve-alpine-base hash to: ${NEW_HASH}"
107+ sed -i "s|eve-alpine-base:[a-f0-9-]*|eve-alpine-base:${NEW_HASH}|g" pkg/alpine/Dockerfile
108+ git diff pkg/alpine/Dockerfile
109+ git config user.name "github-actions[bot]"
110+ git config user.email "github-actions[bot]@users.noreply.github.com"
111+ git add pkg/alpine/Dockerfile
112+ git commit -s -m "alpine-base: update hash to ${NEW_HASH}
113+
114+ Automatically updated by the alpine-base bootstrap workflow.
115+
116+ Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
117+ git push origin HEAD:master
118+
119+ # Step 4: Build eve-alpine for each arch (using the new alpine-base hash)
120+ build-alpine :
121+ needs : commit-hash
122+ permissions :
123+ contents : read
53124 if : github.ref_name == github.event.repository.default_branch
125+ strategy :
126+ fail-fast : false
127+ matrix :
128+ include :
129+ - arch : amd64
130+ runner : zededa-ubuntu-2204
131+ - arch : arm64
132+ runner : zededa-ubuntu-2204-arm64
133+ - arch : riscv64
134+ runner : zededa-ubuntu-2204
135+ runs-on : ${{ matrix.runner }}
136+
137+ steps :
138+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
139+ with :
140+ # Pull the commit we just pushed with the new hash
141+ ref : master
142+ fetch-depth : 0
143+ persist-credentials : false
144+ - name : Set up QEMU for cross-arch builds
145+ if : matrix.arch == 'riscv64'
146+ run : |
147+ APT_INSTALL="sudo apt install -y binfmt-support qemu-user-static"
148+ $APT_INSTALL || { sudo apt update && $APT_INSTALL ; }
149+ - name : Login to Docker Hub
150+ uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
151+ with :
152+ username : ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }}
153+ password : ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
154+ - name : Build and push eve-alpine (${{ matrix.arch }})
155+ run : |
156+ make V=1 ZARCH=${{ matrix.arch }} LINUXKIT_PKG_TARGET=push \
157+ \
158+ LINUXKIT_EXTRA_BUILD_ARGS="--force --disable-cache" \
159+ pkg/alpine
160+
161+ # Step 5: Create multi-arch manifest for eve-alpine
162+ manifest-alpine :
163+ needs : build-alpine
54164 runs-on : zededa-ubuntu-2204
165+ if : github.ref_name == github.event.repository.default_branch
55166 permissions :
56167 contents : read
57168
58169 steps :
59170 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
60171 with :
172+ ref : master
61173 fetch-depth : 0
62174 persist-credentials : false
63175 - name : Login to Docker Hub
64176 uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
65177 with :
66178 username : ${{ secrets.RELEASE_DOCKERHUB_ACCOUNT }}
67179 password : ${{ secrets.RELEASE_DOCKERHUB_TOKEN }}
68- - name : Create multi-arch manifest
180+ - name : Create multi-arch manifest for eve-alpine
69181 run : |
70- make V=1 LINUXKIT_PKG_TARGET=manifest pkg/alpine-base
182+ make V=1 LINUXKIT_PKG_TARGET=manifest \
183+ \
184+ pkg/alpine
0 commit comments