diff --git a/.github/workflows/pre-pull-images.yaml b/.github/workflows/pre-pull-images.yaml index ce59cfc611..a9f1f01a0e 100644 --- a/.github/workflows/pre-pull-images.yaml +++ b/.github/workflows/pre-pull-images.yaml @@ -91,9 +91,6 @@ jobs: app-id: ${{ env.BOT_APP_ID }} private-key: ${{ env.BOT_APP_PRIVATE_KEY }} - - name: Setup Homebrew - uses: Homebrew/actions/setup-homebrew@master - - name: Setup mise uses: jdx/mise-action@v2 with: @@ -156,17 +153,79 @@ jobs: echo "### Images" >> $GITHUB_STEP_SUMMARY echo "${images}" | jq --raw-output 'to_entries[] | "* \(.value)"' >> $GITHUB_STEP_SUMMARY - pre-pull-images: + generate-matrix: if: ${{ needs.extract-images.outputs.matrix != '[]' }} + name: Generate Matrix + runs-on: ubuntu-latest + needs: ["changed-clusters", "extract-images"] + outputs: + matrix: ${{ steps.generate-matrix.outputs.matrix }} + steps: + - name: Setup mise + uses: jdx/mise-action@v2 + with: + mise_toml: | + [tools] + "aqua:mikefarah/yq" = "latest" + + - name: Generate Combined Matrix + id: generate-matrix + run: | + images=${{ needs.extract-images.outputs.matrix }} + clusters=${{ needs.changed-clusters.outputs.matrix }} + + # Define the talosconfig mapping as a valid JSON object + configs=$(echo "${clusters[@]}" | jq -n 'reduce inputs as $cluster ( + {}; + .[$cluster] = "op://Kubernetes/kubernetes/TALOSCONFIG_" + ($cluster | split("/")[1] | ascii_upcase) + )') + + combined=$(echo "$images" | yq eval -j ' + . as $images | + '"$clusters"' as $clusters | + '"$configs"' as $configs | + [ + $images[] as $image | + $clusters[] as $cluster | + { + image: $image, + cluster: $cluster, + talosconfig: $configs[$cluster] + } + ] + ') + + # Output the combined result + echo "Combined: $combined" + + # Save to GITHUB_OUTPUT + echo "matrix=$combined" >> $GITHUB_OUTPUT + + - name: Debug Combined Matrix + run: echo "${{ steps.generate-matrix.outputs.matrix }}" + + pre-pull-images: + if: ${{ needs.generate-matrix.outputs.matrix != '[]' }} name: Pre-pull Images runs-on: ["gha-runner-scale-set"] - needs: ["extract-images"] + needs: ["generate-matrix"] strategy: - matrix: - images: ${{ fromJSON(needs.extract-images.outputs.matrix) }} + matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} max-parallel: 4 fail-fast: false steps: + - name: Configure 1password + uses: 1password/load-secrets-action/configure@v2 + with: + service-account-token: ${{ secrets.ONEPASS_SA_TOKEN }} + + - name: Get Secrets + uses: 1password/load-secrets-action@v2 + with: + export-env: true + env: + TALOSCONFIG: ${{ matrix.talosconfig }} + - name: Setup mise uses: jdx/mise-action@v2 with: