4040 - name : Set up Docker Buildx
4141 uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # ratchet:docker/setup-buildx-action@v4
4242
43+ - name : Set image name
44+ run : echo "IMAGE=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
45+
4346 - name : Log in to GHCR
4447 if : github.event_name != 'pull_request'
4548 uses : docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # ratchet:docker/login-action@v4
5255 id : meta
5356 uses : docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # ratchet:docker/metadata-action@v6
5457 with :
55- images : ghcr.io/ ${{ github.repository }}
58+ images : ${{ env.IMAGE }}
5659 tags : |
5760 type=ref,event=pr
5861 type=raw,value=edge,enable={{is_default_branch}}
7780 if : github.event_name != 'pull_request'
7881 uses : actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # ratchet:actions/attest-build-provenance@v4
7982 with :
80- subject-name : ghcr.io/ ${{ github.repository }}
83+ subject-name : ${{ env.IMAGE }}
8184 subject-digest : ${{ steps.push.outputs.digest }}
8285 push-to-registry : true
8386
9497 - name : Checkout
9598 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
9699
100+ - name : Set image name
101+ run : echo "IMAGE=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
102+
97103 - name : Install grype
98104 run : |
99105 cd /tmp
@@ -106,7 +112,7 @@ jobs:
106112
107113 - name : Scan image
108114 run : |
109- grype ghcr.io/${{ github.repository }} @${{ needs.build-and-push.outputs.digest }} \
115+ grype "${IMAGE} @${{ needs.build-and-push.outputs.digest }}" \
110116 --config .grype.yaml \
111117 -o "template=grype-report.txt" \
112118 -o "json=grype-report.json"
@@ -143,6 +149,9 @@ jobs:
143149 username : ${{ github.actor }}
144150 password : ${{ secrets.GITHUB_TOKEN }}
145151
152+ - name : Set image name
153+ run : echo "IMAGE=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
154+
146155 - name : Install grype
147156 env :
148157 GRYPE_VERSION : " 0.112.0"
@@ -165,15 +174,15 @@ jobs:
165174 run : |
166175 TAG="build-${GITHUB_SHA::7}"
167176 DIGEST=$(docker buildx imagetools inspect \
168- "ghcr.io/${{ github.repository } }:${TAG}" \
177+ "${IMAGE }:${TAG}" \
169178 --format '{{.Manifest.Digest}}')
170179 echo "digest=${DIGEST}" >> "$GITHUB_OUTPUT"
171180 echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
172181 echo "Promoting ${TAG} @ ${DIGEST}"
173182
174183 - name : Scan build image
175184 run : |
176- grype "ghcr.io/${{ github.repository } }@${{ steps.build.outputs.digest }}" \
185+ grype "${IMAGE }@${{ steps.build.outputs.digest }}" \
177186 --config .grype.yaml \
178187 -o "template=grype-report.txt" \
179188 -o "json=grype-report.json"
@@ -191,23 +200,23 @@ jobs:
191200 - name : Promote build image to release tags
192201 run : |
193202 VERSION=${GITHUB_REF_NAME}
194- SOURCE="ghcr.io/${{ github.repository } }@${{ steps.build.outputs.digest }}"
203+ SOURCE="${IMAGE }@${{ steps.build.outputs.digest }}"
195204
196205 if [[ "${VERSION}" == *-* ]]; then
197206 # Pre-release (contains -): push the explicit version tag only.
198207 # Major/minor/latest convenience tags must not point at a pre-release.
199208 echo "Pre-release detected (${VERSION}) — skipping major/minor/latest tags"
200209 docker buildx imagetools create \
201- --tag "ghcr.io/${{ github.repository } }:${VERSION}" \
210+ --tag "${IMAGE }:${VERSION}" \
202211 ${SOURCE}
203212 else
204213 # Stable release: push all convenience tags.
205214 MAJOR=$(echo ${VERSION} | cut -d. -f1)
206215 MINOR=$(echo ${VERSION} | cut -d. -f1-2)
207216 docker buildx imagetools create \
208- --tag "ghcr.io/${{ github.repository } }:${VERSION}" \
209- --tag "ghcr.io/${{ github.repository } }:${MINOR}" \
210- --tag "ghcr.io/${{ github.repository } }:${MAJOR}" \
211- --tag "ghcr.io/${{ github.repository } }:latest" \
217+ --tag "${IMAGE }:${VERSION}" \
218+ --tag "${IMAGE }:${MINOR}" \
219+ --tag "${IMAGE }:${MAJOR}" \
220+ --tag "${IMAGE }:latest" \
212221 ${SOURCE}
213222 fi
0 commit comments