|
46 | 46 | version: latest |
47 | 47 | buildkitd-flags: --debug |
48 | 48 |
|
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 | | - |
59 | 49 | - name: Docker Image |
60 | 50 | id: image |
61 | 51 | shell: bash |
@@ -100,15 +90,50 @@ runs: |
100 | 90 |
|
101 | 91 | cat $GITHUB_OUTPUT |
102 | 92 |
|
| 93 | + - name: Tar file |
| 94 | + id: tar |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + echo "path=/tmp/${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT |
| 98 | +
|
103 | 99 | - name: Build Image |
104 | 100 | id: build |
105 | 101 | uses: docker/bake-action@v4 |
106 | 102 | env: |
107 | 103 | DOCKER_TAG: ${{ steps.tag.outputs.tag }} |
108 | 104 | with: |
109 | 105 | targets: app |
110 | | - push: ${{ inputs.push }} |
111 | | - load: ${{ inputs.push == 'false' }} |
112 | 106 | 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 |
| 107 | + *.output=type=docker,dest=${{ steps.tar.outputs.path }} |
| 108 | +
|
| 109 | + - name: Get image digest |
| 110 | + id: digest |
| 111 | + shell: bash |
| 112 | + run: | |
| 113 | + echo '${{ steps.build.outputs.metadata }}' > metadata.json |
| 114 | + echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT |
| 115 | + cat $GITHUB_OUTPUT |
| 116 | +
|
| 117 | + - name: Upload artifact |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + with: |
| 120 | + name: ${{ steps.meta.outputs.version }} |
| 121 | + path: ${{ steps.tar.outputs.path }} |
| 122 | + retention-days: 1 |
| 123 | + compression-level: 9 |
| 124 | + overwrite: true |
| 125 | + |
| 126 | + - name: Login to Container Registry |
| 127 | + if: inputs.push == 'true' |
| 128 | + uses: docker/login-action@v3 |
| 129 | + with: |
| 130 | + registry: ghcr.io |
| 131 | + username: ${{ inputs.username }} |
| 132 | + password: ${{ inputs.password }} |
| 133 | + |
| 134 | + - name: Push Image |
| 135 | + if: inputs.push == 'true' |
| 136 | + shell: bash |
| 137 | + run: | |
| 138 | + docker load < ${{ steps.tar.outputs.path }} |
| 139 | + docker image push --all-tags ${{ steps.image.outputs.image }} |
0 commit comments