-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tag images correctly during releases
- Loading branch information
Showing
1 changed file
with
22 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,26 +30,30 @@ jobs: | |
- image: executor | ||
dockerfile: ./deploy/Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
name: gcr.io/kaniko-project/executor:${{ github.sha }} | ||
tag: 'latest' | ||
image-name: gcr.io/kaniko-project/executor | ||
tag: ${{ github.sha }} | ||
release-tag: latest | ||
|
||
- image: executor-debug | ||
dockerfile: ./deploy/Dockerfile_debug | ||
platforms: linux/amd64,linux/arm64 | ||
name: gcr.io/kaniko-project/executor:${{ github.sha }}-debug | ||
tag: 'debug' | ||
image-name: gcr.io/kaniko-project/executor | ||
tag: ${{ github.sha }}-debug | ||
release_tag: debug | ||
|
||
- image: executor-slim | ||
dockerfile: ./deploy/Dockerfile_slim | ||
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le | ||
name: gcr.io/kaniko-project/executor:${{ github.sha }}-slim | ||
tag: 'slim' | ||
image-name: gcr.io/kaniko-project/executor | ||
tag: ${{ github.sha }}-slim | ||
release-tag: slim | ||
|
||
- image: warmer | ||
dockerfile: ./deploy/Dockerfile_warmer | ||
name: gcr.io/kaniko-project/warmer:${{ github.sha }} | ||
platforms: linux/amd64,linux/arm64 | ||
tag: '' | ||
image-name: gcr.io/kaniko-project/warmer | ||
tag: ${{ github.sha }} | ||
release-tag: latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
@@ -76,7 +80,7 @@ jobs: | |
file: ${{ matrix.dockerfile }} | ||
platforms: ${{ matrix.platforms }} | ||
push: ${{ github.event_name != 'pull_request' }} # Only push if not a PR. | ||
tags: ${{ matrix.name }} | ||
tags: ${{ matrix.image-name }}:${{ matrix.tag }} | ||
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
@@ -92,20 +96,20 @@ jobs: | |
run: | | ||
cosign sign \ | ||
--kms gcpkms://projects/kaniko-project/locations/global/keyRings/cosign/cryptoKeys/cosign \ | ||
gcr.io/kaniko-project/executor@${{ steps.build-and-push.outputs.digest }} | ||
cosign sign ${{ matrix.name }}@${{ steps.build-and-push.outputs.digest }} | ||
${{ matrix.image }}@${{ steps.build-and-push.outputs.digest }} | ||
cosign sign ${{ matrix.image-name }}@${{ steps.build-and-push.outputs.digest }} | ||
# If a tag push, use crane to add the image tag. | ||
# If a tag push, use crane to add more tags. | ||
- if: startsWith(github.ref, 'refs/tags/v') | ||
uses: imjasonh/[email protected] | ||
- if: startsWith(github.ref, 'refs/tags/v') | ||
name: Apply release tags | ||
run: | | ||
crane cp ${{ matrix.name }}@${{ steps.build-and-push.outputs.digest }} \ | ||
${{ matrix.name }}:${GITHUB_REF/refs\/tags\//} | ||
crane cp ${{ matrix.image-name }}@${{ steps.build-and-push.outputs.digest }} \ | ||
${{ matrix.image-name }}:${GITHUB_REF/refs\/tags\//} | ||
# Also apply executor:${tag} if necessary. | ||
if [[ ! -z "${{ matrix.tag }}" ]]; then | ||
crane cp ${{ matrix.name }}@${{ steps.build-and-push.outputs.digest }} \ | ||
gcr.io/kaniko-project/executor:${{ matrix.tag }} | ||
# Also apply release tags. | ||
if [[ ! -z "${{ matrix.release-tag }}" ]]; then | ||
crane cp ${{ matrix.image-name }}@${{ steps.build-and-push.outputs.digest }} \ | ||
${{ matrix.image-name }}:${{ matrix.release-tag }} | ||
fi |