From ced5b93f1577f3cd3c936a20967d18f2b084ec88 Mon Sep 17 00:00:00 2001 From: Scotte Zinn Date: Wed, 5 Mar 2025 05:39:04 -0500 Subject: [PATCH 1/6] chore: Refactor pull images --- .../{pre-pull-images.yaml => image-pull.yaml} | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-) rename .github/workflows/{pre-pull-images.yaml => image-pull.yaml} (60%) diff --git a/.github/workflows/pre-pull-images.yaml b/.github/workflows/image-pull.yaml similarity index 60% rename from .github/workflows/pre-pull-images.yaml rename to .github/workflows/image-pull.yaml index 9bfcd7e7c..ccc247d47 100644 --- a/.github/workflows/pre-pull-images.yaml +++ b/.github/workflows/image-pull.yaml @@ -1,19 +1,21 @@ --- # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: "Pre-pull Images" +name: Image Pull on: pull_request: branches: ["main"] - paths: ["kubernetes/main/**"] + paths: + - "kubernetes/main/**" + - "kubernetes/repositories/**" concurrency: group: ${{ github.ref }}-${{ github.workflow }} cancel-in-progress: true jobs: - pre-job: - name: Pre-pull Images Pre-Job + setup: + name: Image Pull - Setup runs-on: ubuntu-latest outputs: any_changed: ${{ steps.changed-files.outputs.any_changed }} @@ -27,18 +29,18 @@ jobs: with: files: kubernetes/main/** - extract-images: - name: Extract Images - needs: pre-job + extract: + if: ${{ needs.setup.outputs.any_changed == 'true' }} + name: Image Pull - Extract Images + needs: setup runs-on: ubuntu-latest - if: ${{ needs.pre-job.outputs.any_changed == 'true' }} strategy: matrix: branches: ["default", "pull"] fail-fast: false outputs: - default: ${{ steps.extract-images.outputs.default }} - pull: ${{ steps.extract-images.outputs.pull }} + default: ${{ steps.images.outputs.default }} + pull: ${{ steps.images.outputs.pull }} steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 @@ -58,20 +60,25 @@ jobs: --output-file images.json - name: Output Images - id: extract-images - # shellcheck disable=SC2086 - run: echo "${{ matrix.branches }}=$(jq --compact-output '.' images.json)" >> $GITHUB_OUTPUT + id: images + run: | + echo "${{ matrix.branches }}=$(jq --compact-output '.' images.json)" >> ${GITHUB_OUTPUT} + + echo '## Branch ${{ matrix.branches }} images' >> ${GITHUB_STEP_SUMMARY} + echo '```json' >> ${GITHUB_STEP_SUMMARY} + jq '.' images.json >> ${GITHUB_STEP_SUMMARY} + echo '```' >> ${GITHUB_STEP_SUMMARY} - compare-images: - name: Compare Images + compare: + if: ${{ needs.setup.outputs.any_changed == 'true' && needs.extract-images.outputs.default != needs.extract-images.outputs.pull }} + name: Image Pull - Compare Images runs-on: ubuntu-latest - needs: ["pre-job", "extract-images"] + needs: ["setup", "extract"] outputs: - images: ${{ steps.compare-images.outputs.images }} - if: ${{ needs.pre-job.outputs.any_changed == 'true' && needs.extract-images.outputs.default != needs.extract-images.outputs.pull }} + images: ${{ steps.compare.outputs.images }} steps: - name: Compare Images - id: compare-images + id: compare run: | images=$(jq --compact-output --null-input \ --argjson f1 '${{ needs.extract-images.outputs.default }}' \ @@ -80,28 +87,33 @@ jobs: ) echo "images=${images}" >> "${GITHUB_OUTPUT}" - pre-pull-images: - name: Pre-pull Images - runs-on: ["k8s-homelab-runner"] - needs: ["pre-job", "compare-images"] + echo '## New images to Pull' >> ${GITHUB_STEP_SUMMARY} + echo '```json' >> ${GITHUB_STEP_SUMMARY} + echo $images | jq >> ${GITHUB_STEP_SUMMARY} + echo '```' >> ${GITHUB_STEP_SUMMARY} + + pull: + if: ${{ needs.setup.outputs.any_changed == 'true' && needs.compare.outputs.images != '[]' }} + name: Image Pull - Pull Images + runs-on: k8s-homelab-runner + needs: ["setup", "compare"] strategy: matrix: - images: ${{ fromJSON(needs.compare-images.outputs.images) }} + images: ${{ fromJSON(needs.compare.outputs.images) }} max-parallel: 4 fail-fast: false - if: ${{ needs.pre-job.outputs.any_changed == 'true' && needs.compare-images.outputs.images != '[]' }} steps: - name: Install talosctl run: curl -fsSL https://talos.dev/install | sh - - name: Pre-pull Image + - name: Pull Image run: talosctl -n "${NODE_IP}" image pull ${{ matrix.images }} - pre-pull-images-status: - needs: pre-pull-images - name: Pre-pull Images Success - runs-on: ubuntu-latest + status: if: ${{ always() }} + name: Image Pull - Success + needs: pull + runs-on: ubuntu-latest steps: - name: Any jobs failed? if: ${{ contains(needs.*.result, 'failure') }} From a3c5ea90e8f0bf617bb9074c01997714e1a2099f Mon Sep 17 00:00:00 2001 From: Scotte Zinn Date: Wed, 5 Mar 2025 05:53:34 -0500 Subject: [PATCH 2/6] Fix shellcheck errors --- .github/workflows/image-pull.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/image-pull.yaml b/.github/workflows/image-pull.yaml index ccc247d47..4416874fe 100644 --- a/.github/workflows/image-pull.yaml +++ b/.github/workflows/image-pull.yaml @@ -62,12 +62,12 @@ jobs: - name: Output Images id: images run: | - echo "${{ matrix.branches }}=$(jq --compact-output '.' images.json)" >> ${GITHUB_OUTPUT} + echo "${{ matrix.branches }}=$(jq --compact-output '.' images.json)" >> "${GITHUB_OUTPUT}" - echo '## Branch ${{ matrix.branches }} images' >> ${GITHUB_STEP_SUMMARY} - echo '```json' >> ${GITHUB_STEP_SUMMARY} - jq '.' images.json >> ${GITHUB_STEP_SUMMARY} - echo '```' >> ${GITHUB_STEP_SUMMARY} + echo '## Branch ${{ matrix.branches }} images' >> "${GITHUB_STEP_SUMMARY}" + echo '```json' >> "${GITHUB_STEP_SUMMARY}" + jq '.' images.json >> "${GITHUB_STEP_SUMMARY}" + echo '```' >> "${GITHUB_STEP_SUMMARY}" compare: if: ${{ needs.setup.outputs.any_changed == 'true' && needs.extract-images.outputs.default != needs.extract-images.outputs.pull }} @@ -87,10 +87,10 @@ jobs: ) echo "images=${images}" >> "${GITHUB_OUTPUT}" - echo '## New images to Pull' >> ${GITHUB_STEP_SUMMARY} - echo '```json' >> ${GITHUB_STEP_SUMMARY} - echo $images | jq >> ${GITHUB_STEP_SUMMARY} - echo '```' >> ${GITHUB_STEP_SUMMARY} + echo '## New images to Pull' >> "${GITHUB_STEP_SUMMARY}" + echo '```json' >> "${GITHUB_STEP_SUMMARY}" + echo $images | jq >> "${GITHUB_STEP_SUMMARY}" + echo '```' >> "${GITHUB_STEP_SUMMARY}" pull: if: ${{ needs.setup.outputs.any_changed == 'true' && needs.compare.outputs.images != '[]' }} From 3d3e88a93d4eafefd25b282ad18a4daaf9433dab Mon Sep 17 00:00:00 2001 From: Scotte Zinn Date: Wed, 5 Mar 2025 05:56:34 -0500 Subject: [PATCH 3/6] Fix shellcheck errors --- .github/workflows/image-pull.yaml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/image-pull.yaml b/.github/workflows/image-pull.yaml index 4416874fe..52a79d2f1 100644 --- a/.github/workflows/image-pull.yaml +++ b/.github/workflows/image-pull.yaml @@ -64,13 +64,15 @@ jobs: run: | echo "${{ matrix.branches }}=$(jq --compact-output '.' images.json)" >> "${GITHUB_OUTPUT}" - echo '## Branch ${{ matrix.branches }} images' >> "${GITHUB_STEP_SUMMARY}" - echo '```json' >> "${GITHUB_STEP_SUMMARY}" - jq '.' images.json >> "${GITHUB_STEP_SUMMARY}" - echo '```' >> "${GITHUB_STEP_SUMMARY}" + { + echo '## Branch ${{ matrix.branches }} images' + echo '```json' + jq '.' images.json + echo '```' + } >> "${GITHUB_STEP_SUMMARY}" compare: - if: ${{ needs.setup.outputs.any_changed == 'true' && needs.extract-images.outputs.default != needs.extract-images.outputs.pull }} + if: ${{ needs.setup.outputs.any_changed == 'true' && needs.extract.outputs.default != needs.extract.outputs.pull }} name: Image Pull - Compare Images runs-on: ubuntu-latest needs: ["setup", "extract"] @@ -87,10 +89,12 @@ jobs: ) echo "images=${images}" >> "${GITHUB_OUTPUT}" - echo '## New images to Pull' >> "${GITHUB_STEP_SUMMARY}" - echo '```json' >> "${GITHUB_STEP_SUMMARY}" - echo $images | jq >> "${GITHUB_STEP_SUMMARY}" - echo '```' >> "${GITHUB_STEP_SUMMARY}" + { + echo '## New images to Pull' + echo '```json' + echo $images | jq + echo '```' + } >> "${GITHUB_STEP_SUMMARY}" pull: if: ${{ needs.setup.outputs.any_changed == 'true' && needs.compare.outputs.images != '[]' }} From 53164363e1080931952a341271b0ac4e443daa33 Mon Sep 17 00:00:00 2001 From: Scotte Zinn Date: Wed, 5 Mar 2025 05:59:34 -0500 Subject: [PATCH 4/6] Fix shellcheck errors --- .github/workflows/image-pull.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/image-pull.yaml b/.github/workflows/image-pull.yaml index 52a79d2f1..e1edab4c1 100644 --- a/.github/workflows/image-pull.yaml +++ b/.github/workflows/image-pull.yaml @@ -83,8 +83,8 @@ jobs: id: compare run: | images=$(jq --compact-output --null-input \ - --argjson f1 '${{ needs.extract-images.outputs.default }}' \ - --argjson f2 '${{ needs.extract-images.outputs.pull }}' \ + --argjson f1 '${{ needs.extract.outputs.default }}' \ + --argjson f2 '${{ needs.extract.outputs.pull }}' \ '$f2 - $f1' \ ) echo "images=${images}" >> "${GITHUB_OUTPUT}" From 4f4ec9853408c16f90b3c44127e89a8f877900ad Mon Sep 17 00:00:00 2001 From: Scotte Zinn Date: Wed, 5 Mar 2025 06:02:34 -0500 Subject: [PATCH 5/6] Fix shellcheck errors --- .github/workflows/image-pull.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/image-pull.yaml b/.github/workflows/image-pull.yaml index e1edab4c1..40572de8a 100644 --- a/.github/workflows/image-pull.yaml +++ b/.github/workflows/image-pull.yaml @@ -82,11 +82,11 @@ jobs: - name: Compare Images id: compare run: | - images=$(jq --compact-output --null-input \ + images="$(jq --compact-output --null-input \ --argjson f1 '${{ needs.extract.outputs.default }}' \ --argjson f2 '${{ needs.extract.outputs.pull }}' \ '$f2 - $f1' \ - ) + )" echo "images=${images}" >> "${GITHUB_OUTPUT}" { From 5a77b25dd72d46e1a286f95840bb5d72bbaa211c Mon Sep 17 00:00:00 2001 From: Scotte Zinn Date: Wed, 5 Mar 2025 06:04:14 -0500 Subject: [PATCH 6/6] Fix shellcheck errors --- .github/workflows/image-pull.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/image-pull.yaml b/.github/workflows/image-pull.yaml index 40572de8a..eba1883a4 100644 --- a/.github/workflows/image-pull.yaml +++ b/.github/workflows/image-pull.yaml @@ -82,17 +82,17 @@ jobs: - name: Compare Images id: compare run: | - images="$(jq --compact-output --null-input \ + images=$(jq --compact-output --null-input \ --argjson f1 '${{ needs.extract.outputs.default }}' \ --argjson f2 '${{ needs.extract.outputs.pull }}' \ '$f2 - $f1' \ - )" + ) echo "images=${images}" >> "${GITHUB_OUTPUT}" { echo '## New images to Pull' echo '```json' - echo $images | jq + echo "${images}" | jq echo '```' } >> "${GITHUB_STEP_SUMMARY}"