-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate PR and real release workflows #1845
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: Build images | ||
|
||
on: | ||
pull_request: | ||
branches: ['master'] | ||
push: | ||
branches: ['master'] | ||
tags: ['v[0-9]+.[0-9]+.[0-9]+*'] | ||
|
||
concurrency: | ||
group: release-images-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-images: | ||
permissions: | ||
contents: read # Read the repo contents. | ||
id-token: write # Produce identity token for keyless signing. | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
image: | ||
- executor | ||
- executor-debug | ||
- executor-slim | ||
- warmer | ||
|
||
include: | ||
- image: executor | ||
dockerfile: ./deploy/Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
name: gcr.io/kaniko-project/executor:${{ github.sha }} | ||
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: 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: warmer | ||
dockerfile: ./deploy/Dockerfile_warmer | ||
name: gcr.io/kaniko-project/warmer:${{ github.sha }} | ||
platforms: linux/amd64,linux/arm64 | ||
tag: '' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Setup auth if not a PR. | ||
- if: github.event_name != 'pull_request' | ||
uses: google-github-actions/setup-gcloud@master | ||
with: | ||
service_account_key: ${{ secrets.GCR_DEVOPS_SERVICE_ACCOUNT_KEY }} | ||
project_id: kaniko-project | ||
export_default_credentials: true | ||
- if: github.event_name != 'pull_request' | ||
run: gcloud auth configure-docker | ||
|
||
# Build and push with Docker. | ||
- uses: docker/setup-qemu-action@v1 | ||
with: | ||
platforms: ${{ matrix.platforms }} | ||
- uses: docker/setup-buildx-action@v1 | ||
- uses: docker/build-push-action@v2 | ||
id: build-and-push | ||
with: | ||
context: . | ||
file: ${{ matrix.dockerfile }} | ||
platforms: ${{ matrix.platforms }} | ||
push: ${{ github.event_name != 'pull_request' }} # Only push if not a PR. | ||
tags: ${{ matrix.name }} | ||
# 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 | ||
|
||
# Sign images if not a PR. | ||
- if: github.event_name != 'pull_request' | ||
uses: sigstore/cosign-installer@main | ||
with: | ||
cosign-release: 'v1.4.1' | ||
- if: github.event_name != 'pull_request' | ||
env: | ||
COSIGN_EXPERIMENTAL: "true" | ||
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 }} | ||
|
||
# If a tag push, use crane to add the image tag. | ||
- 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\//} | ||
imjasonh marked this conversation as resolved.
Show resolved
Hide resolved
imjasonh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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 }} | ||
fi | ||
imjasonh marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid the cache on releases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That feels a bit overly paranoid, but sure. Is there some public guidance around building release without caches that I can link to in a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s a strict interpretation of some of the higher SLSA levels, and one build being able to influence others.