Skip to content

Commit

Permalink
feat: Cache CI-built cloud-provider-kind Docker image (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
nialdaly authored Jan 16, 2025
1 parent 14bf4f5 commit 6b51407
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .github/actions/cache-cloud-provider-kind-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Cache cloud-provider-kind image
description: Checks out, builds, and caches the cloud-provider-kind image

runs:
using: composite
steps:
- name: Checkout cloud-provider-kind repo
uses: actions/checkout@v4
with:
repository: kubernetes-sigs/cloud-provider-kind
path: cloud-provider-kind

- name: Generate cloud-provider-kind image cache key
id: cloud-provider-kind-cache-key
shell: bash
run: echo "hash=$(cd cloud-provider-kind && git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Cache cloud-provider-kind image
id: cloud-provider-kind-cache
uses: actions/cache@v3
with:
path: /tmp/cloud-provider-kind-image
key: cloud-provider-kind-${{ steps.cloud-provider-kind-cache-key.outputs.hash }}

- name: Load cached image
if: steps.cloud-provider-kind-cache.outputs.cache-hit == 'true'
shell: bash
run: docker load < /tmp/cloud-provider-kind-image

- name: Set up Docker Buildx
if: steps.cloud-provider-kind-cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v3

- name: Build cloud-provider-kind image
if: steps.cloud-provider-kind-cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v6
with:
context: ./cloud-provider-kind
push: false
tags: cloud-provider-kind-cloud-provider:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/cloud-provider-kind-image
8 changes: 7 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: integration
on:
push:
branches:
- main
pull_request:

jobs:
single-trust-zone:
name: single trust zone
Expand All @@ -24,6 +24,9 @@ jobs:
- name: Build and run tests
run: just build

- name: Build and cache cloud-provider-kind image
uses: ./.github/actions/cache-cloud-provider-kind-image

- name: Install kind
run: just install-kind

Expand Down Expand Up @@ -62,6 +65,9 @@ jobs:
- name: Build and run tests
run: just build

- name: Build and cache cloud-provider-kind image
uses: ./.github/actions/cache-cloud-provider-kind-image

- name: Build and install test plugin
run: just install-test-plugin
if: ${{ matrix.plugin == 'cofidectl-test-plugin' }}
Expand Down

0 comments on commit 6b51407

Please sign in to comment.