@@ -20,21 +20,40 @@ jobs:
2020 docker :
2121 name : Build Docker images
2222 runs-on : ubuntu-24.04
23+ permissions :
24+ packages : read
2325 steps :
2426 - uses : actions/checkout@v4
2527 - name : Build base image
28+ if : github.event_name == 'push'
2629 run : make -C scripts/docker build VARIANT=base TAG=$IMAGE_TAG
30+ - name : Build base-build image
31+ if : github.event_name == 'push'
32+ run : make -C scripts/docker build VARIANT=base-build TAG=$IMAGE_TAG
33+ - uses : docker/login-action@v3
34+ if : github.event_name == 'pull_request' || github.event_name == 'merge_group'
35+ with :
36+ registry : ghcr.io
37+ username : ${{ github.actor }}
38+ password : ${{ secrets.GITHUB_TOKEN }}
39+ - name : Retrieve base-build image
40+ if : github.event_name == 'pull_request' || github.event_name == 'merge_group'
41+ run : |
42+ docker pull ghcr.io/easycrypt/ec-base-build-box:main
43+ docker tag ghcr.io/easycrypt/ec-base-build-box:main ghcr.io/easycrypt/ec-base-build-box:$IMAGE_TAG
2744 - name : Build build image
28- run : make -C scripts/docker build VARIANT=build TAG=$IMAGE_TAG
45+ run : make -C scripts/docker build VARIANT=build TAG=$IMAGE_TAG BARGS='--build-arg BASE_BUILD_LAYER=ghcr.io/easycrypt/ec-base-build-box:${IMAGE_TAG}'
2946 - name : Save images for downstream jobs
3047 run : |
3148 docker save "ghcr.io/easycrypt/ec-base-box:$IMAGE_TAG" | gzip > base-image.tar.gz
49+ docker save "ghcr.io/easycrypt/ec-base-build-box:$IMAGE_TAG" | gzip > base-build-image.tar.gz
3250 docker save "ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" | gzip > build-image.tar.gz
3351 - uses : actions/upload-artifact@v4
3452 with :
3553 name : docker-images
3654 path : |
3755 base-image.tar.gz
56+ base-build-image.tar.gz
3857 build-image.tar.gz
3958 retention-days : 1
4059
@@ -228,12 +247,7 @@ jobs:
228247 publish :
229248 name : Publish Docker images
230249 if : |
231- github.event_name == 'push' && (
232- github.ref == 'refs/heads/main' ||
233- github.ref == 'refs/heads/release' ||
234- github.ref == 'refs/heads/latest' ||
235- startsWith(github.ref, 'refs/tags/r')
236- )
250+ github.event_name == 'push'
237251 needs : [compile-opam, compile-nix, check, external, external-status, docker]
238252 runs-on : ubuntu-24.04
239253 permissions :
@@ -255,6 +269,12 @@ jobs:
255269 docker tag "ghcr.io/easycrypt/ec-base-box:$IMAGE_TAG" \
256270 "ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}"
257271 docker push "ghcr.io/easycrypt/ec-base-box:${{ github.ref_name }}"
272+ - name : Push base-build image
273+ if : github.ref_name == 'main'
274+ run : |
275+ docker tag "ghcr.io/easycrypt/ec-base-build-box:$IMAGE_TAG" \
276+ "ghcr.io/easycrypt/ec-base-build-box:${{ github.ref_name }}"
277+ docker push "ghcr.io/easycrypt/ec-base-build-box:${{ github.ref_name }}"
258278 - name : Push build image
259279 run : |
260280 docker tag "ghcr.io/easycrypt/ec-build-box:$IMAGE_TAG" \
@@ -266,8 +286,8 @@ jobs:
266286 github.ref == 'refs/heads/latest' ||
267287 github.ref_type == 'tag'
268288 run : |
269- make -C scripts/docker build VARIANT=test TAG=${{ github.ref_name }}
270- make -C scripts/docker publish VARIANT=test TAG= ${{ github.ref_name }}
289+ make -C scripts/docker build publish VARIANT=test TAG=${{ github.ref_name }} \
290+ BARGS='--build-arg BUILD_LAYER=ghcr.io/easycrypt/ec-build-box: ${{ github.ref_name }}'
271291
272292 # ── Notification ──
273293
0 commit comments