11name : ' Docker Build'
22description : ' Builds docker image'
33inputs :
4- push :
5- required : true
6- description : " Build and push image to registry (cannot be used together with load)"
7- default : " false"
8- password :
9- required : false
10- description : " Password for the registry"
11- username :
12- required : false
13- description : " Username for the registry"
144 node_env :
155 required : false
166 description : " Node environment"
@@ -30,9 +20,9 @@ outputs:
3020 image :
3121 description : " The Docker image"
3222 value : ${{ steps.image.outputs.image }}
33- image_version :
23+ tag :
3424 description : " Combines image and version to a valid image tag"
35- value : ${{ steps.image .outputs.image }}:${{ steps.meta.outputs.version }}
25+ value : ${{ steps.tag .outputs.tag }}
3626
3727runs :
3828 using : " composite"
@@ -46,28 +36,11 @@ runs:
4636 version : latest
4737 buildkitd-flags : --debug
4838
49- # Login to a registry to push the image
50- - name : Login to Container Registry
51- # Only login if we are pushing the image
52- if : ${{ inputs.push == 'true' }}
53- uses : docker/login-action@v3
54- with :
55- registry : ghcr.io
56- username : ${{ inputs.username }}
57- password : ${{ inputs.password }}
58-
5939 - name : Docker Image
6040 id : image
6141 shell : bash
6242 run : |
63- registry="ghcr.io"
64- repository="${{ github.repository }}"
65- image="$registry/$repository"
66-
67- echo "registry=$registry" >> $GITHUB_OUTPUT
68- echo "repository=$repository" >> $GITHUB_OUTPUT
69- echo "image=$image" >> $GITHUB_OUTPUT
70-
43+ echo "image=${{ github.repository }}" >> $GITHUB_OUTPUT
7144 cat $GITHUB_OUTPUT
7245
7346 - name : Docker meta
@@ -100,15 +73,35 @@ runs:
10073
10174 cat $GITHUB_OUTPUT
10275
76+ - name : Tar file
77+ id : tar
78+ shell : bash
79+ run : |
80+ echo "path=/tmp/${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
81+
10382 - name : Build Image
10483 id : build
10584 uses : docker/bake-action@v4
10685 env :
10786 DOCKER_TAG : ${{ steps.tag.outputs.tag }}
10887 with :
10988 targets : app
110- push : ${{ inputs.push }}
111- load : ${{ inputs.push == 'false' }}
11289 set : |
113- *.cache-from=type=registry,ref=${{ steps.tag.outputs.tag_cache }}
114- *.cache-to=type=registry,ref=${{ steps.tag.outputs.tag_cache }},mode=max,compression-level=9,force-compression=true,ignore-error=true
90+ *.output=type=docker,dest=${{ steps.tar.outputs.path }}
91+
92+ - name : Get image digest
93+ id : digest
94+ shell : bash
95+ run : |
96+ echo '${{ steps.build.outputs.metadata }}' > metadata.json
97+ echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT
98+ cat $GITHUB_OUTPUT
99+
100+ - name : Upload artifact
101+ uses : actions/upload-artifact@v4
102+ with :
103+ name : ${{ steps.meta.outputs.version }}
104+ path : ${{ steps.tar.outputs.path }}
105+ retention-days : 1
106+ compression-level : 9
107+ overwrite : true
0 commit comments