Skip to content

Commit

Permalink
feat: make job into multi-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
joryirving committed Dec 28, 2024
1 parent 7ec5792 commit 470a4e4
Showing 1 changed file with 64 additions and 6 deletions.
70 changes: 64 additions & 6 deletions .github/workflows/pre-pull-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -156,17 +153,78 @@ jobs:
echo "### Images" >> $GITHUB_STEP_SUMMARY
echo "${images}" | jq --raw-output 'to_entries[] | "* \(.value)"' >> $GITHUB_STEP_SUMMARY
generate-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 }}
# Map clusters to their corresponding talosconfig files
configs=$(jq -n '
{
"kubernetes/main": "op://Kubernetes/kubernetes/TALOSCONFIG_MAIN",
"kubernetes/utility": "op://Kubernetes/kubernetes/TALOSCONFIG_UTILITY"
}
')
# Combine images with cluster and talosconfig mappings
combined=$(jq -n --argjson images "$images" --argjson clusters "$clusters" --argjson configs "$configs" '
[
$images[] as $image |
$clusters[] as $cluster |
{
image: $image,
cluster: $cluster,
talosconfig: $configs[$cluster]
}
]
')
echo "Images: $images"
echo "Clusters: $clusters"
echo "Configs: $configs"
echo "Combined: $combined"
echo "matrix=$combined" >> $GITHUB_OUTPUT
- name: Debug Combined Matrix
run: echo "${{ steps.generate-matrix.outputs.matrix }}"

pre-pull-images:
if: ${{ needs.extract-images.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:
Expand Down

0 comments on commit 470a4e4

Please sign in to comment.