From c972756130a1eed1237ec374db43e8ea572cc474 Mon Sep 17 00:00:00 2001 From: nialdaly Date: Thu, 16 Jan 2025 10:56:23 +0000 Subject: [PATCH] [From review] Utilise composite action --- .../action.yml | 44 +++++++++++ .github/workflows/integration.yml | 76 +------------------ 2 files changed, 48 insertions(+), 72 deletions(-) create mode 100644 .github/actions/cache-cloud-provider-kind-image/action.yml diff --git a/.github/actions/cache-cloud-provider-kind-image/action.yml b/.github/actions/cache-cloud-provider-kind-image/action.yml new file mode 100644 index 0000000..2a711d3 --- /dev/null +++ b/.github/actions/cache-cloud-provider-kind-image/action.yml @@ -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 diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 0260dbe..8a5dc20 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -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 @@ -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