Skip to content

Commit

Permalink
[From review] Utilise composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
nialdaly committed Jan 16, 2025
1 parent 836fa69 commit c972756
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 72 deletions.
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
76 changes: 4 additions & 72 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,8 @@ jobs:
- name: Build and run tests
run: just build

- 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
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'
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
- 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 @@ -99,42 +65,8 @@ jobs:
- name: Build and run tests
run: just build

- 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
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'
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
- 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
Expand Down

0 comments on commit c972756

Please sign in to comment.