@@ -455,15 +455,16 @@ jobs:
455455 runs-on :
456456 - " ubuntu-latest"
457457 - " ubuntu-24.04-arm"
458+ outputs :
459+ image_name : ${{ steps.image_name.outputs.image_name }}
460+ unique_tag : ${{ steps.unique_tag.outputs.unique_tag }}
461+ application_name : ${{ steps.application_name.outputs.application_name }}
462+ registry : ${{ env.REGISTRY }}
458463 runs-on : ${{ matrix.runs-on }}
459464 needs :
460465 - calculate-version
461466 # if:
462467 # ... is not needed because calculate-version will not run if we disable building the docker container
463- env :
464- APPLICATION_NAME : PLACEHOLDER # overridden in step 'Set application name', this is merely to satisfy the linter
465- PATH_TO_TAR : PLACEHOLDER # same ^
466- UNIQUE_TAG : PLACEHOLDER # same ^
467468 steps :
468469 - name : Checkout
469470 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -517,24 +518,33 @@ jobs:
517518
518519 - name : Lowercase the image name
519520 shell : bash
521+ id : image_name
520522 run : |
521- echo "IMAGE_NAME =${IMAGE_NAME,,}" >> ${GITHUB_ENV }
523+ echo "image_name =${IMAGE_NAME,,}" >> ${GITHUB_OUTPUT }
522524
523525 - name : Set Docker tag
524526 shell : bash
527+ id : unique_tag
525528 run : |
526529 unique_tag=pr-${{ github.event.pull_request.base.sha }}-${{ github.event.pull_request.head.sha }}
527- echo "UNIQUE_TAG=${unique_tag##*/}" >> ${GITHUB_ENV}
530+ echo "unique_tag=${unique_tag##*/}" >> ${GITHUB_OUTPUT}
531+
532+ - name : Set application name
533+ shell : bash
534+ id : application_name
535+ run : |
536+ application_name=${{ github.repository }}
537+ echo "application_name=${application_name##*/}" >> ${GITHUB_OUTPUT}
528538
529539 # Extract metadata (tags, labels) for Docker
530540 # https://github.com/docker/metadata-action
531541 - name : Extract Docker metadata
532542 uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
533543 id : meta
534544 with :
535- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
545+ images : ${{ env.REGISTRY }}/${{ steps.image_name.outputs.image_name }}
536546 tags : |
537- type=raw,value=${{ env.UNIQUE_TAG }}
547+ type=raw,value=${{ steps.unique_tag.outputs.unique_tag }}
538548 labels : |
539549 org.opencontainers.image.version=pr-${{ github.event.number }}
540550 org.opencontainers.image.source=${{ github.event.pull_request.html_url }}
@@ -546,34 +556,28 @@ jobs:
546556 username : ${{ github.actor }}
547557 password : ${{ secrets.GITHUB_TOKEN }}
548558
549- - name : Set application name
550- shell : bash
551- run : |
552- application_name=${{ github.repository }}
553- echo "APPLICATION_NAME=${application_name##*/}" >> ${GITHUB_ENV}
554-
555559 - name : Build Docker image
556560 uses : docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0 # v6.17.0
557561 with :
558562 build-args : |
559- APPLICATION_NAME=${{ env.APPLICATION_NAME }}
563+ APPLICATION_NAME=${{ steps.application_name.outputs.application_name }}
560564 context : .
561565 # this container is THE PR's artifact, and we will re-tag it
562566 # once the PR has been accepted
563567 tags : ${{ steps.meta.outputs.tags }}
564568 labels : ${{ steps.meta.outputs.labels }}
565- cache-from : type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ env.APPLICATION_NAME }}
566- cache-to : type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ env.APPLICATION_NAME }},mode=max
569+ cache-from : type=registry,ref=${{ env.REGISTRY }}/${{ steps.image_name.outputs.image_name }}:buildcache-${{ steps.application_name.outputs.application_name }}
570+ cache-to : type=registry,ref=${{ env.REGISTRY }}/${{ steps.image_name.outputs.image_name }}:buildcache-${{ steps.application_name.outputs.application_name }},mode=max
567571 platforms : linux/amd64, linux/arm64
568- outputs : type=oci,dest=/tmp/${{ env.UNIQUE_TAG }}.tar
572+ outputs : type=oci,dest=/tmp/${{ steps.unique_tag.outputs.unique_tag }}.tar
569573
570574 - name : Upload artifact
571575 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
572576 if : |
573577 matrix.runs-on == 'ubuntu-latest'
574578 with :
575- name : container-${{ env.APPLICATION_NAME }}
576- path : /tmp/${{ env.UNIQUE_TAG }}.tar
579+ name : container-${{ steps.application_name.outputs.application_name }}
580+ path : /tmp/${{ steps.unique_tag.outputs.unique_tag }}.tar
577581 if-no-files-found : error
578582 retention-days : 1
579583
@@ -582,9 +586,6 @@ jobs:
582586 runs-on : ubuntu-latest
583587 needs :
584588 - docker-build
585- env :
586- APPLICATION_NAME : PLACEHOLDER # overridden in step 'Set application name', this is merely to satisfy the linter
587- UNIQUE_TAG : PLACEHOLDER # same ^
588589 # Check if the event is not triggered by a fork
589590 if : |
590591 github.event.pull_request.head.repo.full_name == github.repository &&
@@ -600,55 +601,38 @@ jobs:
600601 }
601602 }
602603
603- - name : Log into registry ${{ env.REGISTRY }}
604+ - name : Log into registry ${{ needs.docker-build.outputs.registry }}
604605 uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
605606 with :
606- registry : ${{ env.REGISTRY }}
607+ registry : ${{ needs.docker-build.outputs.registry }}
607608 username : ${{ github.actor }}
608609 password : ${{ secrets.GITHUB_TOKEN }}
609610
610- - name : Lowercase the image name
611- shell : bash
612- run : |
613- echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}
614-
615- - name : Set application name
616- shell : bash
617- run : |
618- application_name=${{ github.repository }}
619- echo "APPLICATION_NAME=${application_name##*/}" >> ${GITHUB_ENV}
620-
621- - name : Set Docker tag (which is also the filename.tar)
622- shell : bash
623- run : |
624- unique_tag=pr-${{ github.event.pull_request.base.sha }}-${{ github.event.pull_request.head.sha }}
625- echo "UNIQUE_TAG=${unique_tag##*/}" >> ${GITHUB_ENV}
626-
627611 - name : Extract Docker metadata
628612 uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
629613 id : meta
630614 with :
631- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
615+ images : ${{ needs.docker-build.outputs.registry }}/${{ needs.docker-build.outputs.image_name }}
632616 tags : |
633617 type=ref,event=pr,suffix=-latest
634- type=raw,value=${{ env.UNIQUE_TAG }}
618+ type=raw,value=${{ needs.docker-build.outputs.unique_tag }}
635619
636620 - name : Download artifact
637621 uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
638622 id : artifact
639623 with :
640624 path : /tmp/container/
641- name : container-${{ env.APPLICATION_NAME }}
625+ name : container-${{ needs.docker-build.outputs.application_name }}
642626
643627 - name : Load images from artifacts
644628 shell : bash
645629 run : |
646- docker load --input ${{ steps.artifact.outputs.download-path }}/${{ env.UNIQUE_TAG }}.tar
630+ docker load --input ${{ steps.artifact.outputs.download-path }}/${{ needs.docker-build.outputs.unique_tag }}.tar
647631
648632 - name : Push image to register
649633 shell : bash
650634 run : |
651- base_tag=$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:%s ' ${{ env.UNIQUE_TAG }})
635+ base_tag=$(printf '${{ needs.docker-build.outputs.registry }}/${{ needs.docker-build.outputs.image_name }}:%s ' ${{ needs.docker-build.outputs.unique_tag }})
652636
653637 docker push ${base_tag}
654638
@@ -659,7 +643,7 @@ jobs:
659643 new_tags="${{ join(steps.meta.outputs.tags, ' ') }}"
660644 new_tags=$(printf -- '--tag %s ' $new_tags)
661645
662- base_tag=$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:%s ' ${{ env.UNIQUE_TAG }})
646+ base_tag=$(printf '${{ needs.docker-build.outputs.registry }}/${{ needs.docker-build.outputs.image_name }}:%s ' ${{ needs.docker-build.outputs.unique_tag }})
663647
664648 docker buildx imagetools create $new_tags $base_tag
665649
0 commit comments