Skip to content
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

Attempt to speed up PR image builds by sharing a cache #1844

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 40 additions & 150 deletions .github/workflows/pr_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,165 +7,55 @@ concurrency:
cancel-in-progress: true

jobs:
build-executor-slim:
build-images:
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
PLATFORMS: "linux/amd64,linux/arm64,linux/s390x,linux/ppc64le"
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2

- name: Get the tags
id: vars
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ env.PLATFORMS }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest


- uses: docker/build-push-action@v2
with:
context: .
file: ./deploy/Dockerfile_slim
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
tags: |
gcr.io/kaniko-project/executor:${{ env.GITHUB_SHA }}-slim

build-debug:
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
PLATFORMS: "linux/amd64,linux/arm64"
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2

- name: Get the tags
id: vars
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ env.PLATFORMS }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: 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 }}

- image: executor-debug
dockerfile: ./deploy/Dockerfile_debug
platforms: linux/amd64,linux/arm64
name: gcr.io/kaniko-project/executor:${{ github.sha }}-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

- image: warmer
dockerfile: ./deploy/Dockerfile_warmer
name: gcr.io/kaniko-project/warmer:${{ github.sha }}
platforms: linux/amd64,linux/arm64

- uses: docker/build-push-action@v2
with:
context: .
file: ./deploy/Dockerfile_debug
platforms: linux/amd64,linux/arm64
tags: |
gcr.io/kaniko-project/executor:${{ env.GITHUB_SHA }}-debug

build-warmer:
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
PLATFORMS: "linux/amd64,linux/arm64"
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2

- name: Get the tags
id: vars
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ env.PLATFORMS }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- uses: docker/build-push-action@v2
with:
context: .
file: ./deploy/Dockerfile_warmer
platforms: linux/amd64,linux/arm64
tags: |
gcr.io/kaniko-project/warmer:${{ env.GITHUB_SHA }}

build-executor:
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
PLATFORMS: "linux/amd64,linux/arm64"
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2

- name: Get the tags
id: vars
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- uses: docker/setup-qemu-action@v1
with:
platforms: ${{ env.PLATFORMS }}
platforms: ${{ matrix.platforms }}

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
- uses: docker/setup-buildx-action@v1

- uses: docker/build-push-action@v2
with:
context: .
file: ./deploy/Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
gcr.io/kaniko-project/executor:${{ env.GITHUB_SHA }}
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platforms }}
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