|
| 1 | +name: Create and publish toolkit base image |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +env: |
| 7 | + REGISTRY: ghcr.io |
| 8 | + IMAGE_NAME: ${{ github.repository_owner }}/eks-toolkit-base |
| 9 | + BUILD_CONTEXT: tests/images/toolkit-base/ |
| 10 | + |
| 11 | +jobs: |
| 12 | + get_versions_job: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + k8s_versions: ${{ steps.determine_versions.outputs.k8s_versions }} |
| 16 | + latest_tools: ${{ steps.determine_versions.outputs.latest_tools }} |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + - name: Install jq |
| 22 | + run: sudo apt-get update && sudo apt-get install -y jq |
| 23 | + |
| 24 | + - name: Determine K8s Versions and Tool Versions |
| 25 | + id: determine_versions |
| 26 | + working-directory: ${{ env.BUILD_CONTEXT }} |
| 27 | + run: | |
| 28 | + chmod +x ./get_versions_matrix.sh # We need a new version of the script |
| 29 | + ./get_versions_matrix.sh |
| 30 | +
|
| 31 | + build_and_push_image: |
| 32 | + needs: get_versions_job |
| 33 | + runs-on: ubuntu-latest |
| 34 | + permissions: |
| 35 | + contents: read |
| 36 | + packages: write |
| 37 | + attestations: write |
| 38 | + id-token: write |
| 39 | + |
| 40 | + strategy: |
| 41 | + fail-fast: false # Optional: Set to false if you want other builds to finish even if one fails |
| 42 | + matrix: |
| 43 | + k8s_tag: ${{ fromJson(needs.get_versions_job.outputs.k8s_versions) }} |
| 44 | + steps: |
| 45 | + - name: Checkout repository |
| 46 | + uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Setup QEMU |
| 49 | + uses: docker/setup-qemu-action@v3 |
| 50 | + |
| 51 | + - name: Setup docker buildx |
| 52 | + uses: docker/setup-buildx-action@v3 |
| 53 | + |
| 54 | + - name: Log in to the Container registry |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ${{ env.REGISTRY }} |
| 58 | + username: ${{ github.actor }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Set Image Tag for Matrix Run |
| 62 | + id: tags |
| 63 | + run: | |
| 64 | + # Use the K8s version as the primary tag |
| 65 | + echo "tag=${{ matrix.k8s_tag }}" >> $GITHUB_OUTPUT |
| 66 | +
|
| 67 | + - name: Build and push Docker image |
| 68 | + uses: docker/build-push-action@v6 |
| 69 | + with: |
| 70 | + context: ${{ env.BUILD_CONTEXT }} |
| 71 | + platforms: linux/amd64,linux/arm64 |
| 72 | + push: true |
| 73 | + # The tags are set dynamically by the 'Set Image Tag' step |
| 74 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:${{ steps.tags.outputs.tag }} |
| 75 | + |
| 76 | + # Extract the static tool versions from the needs output |
| 77 | + build-args: | |
| 78 | + KUBECTL_VERSION=${{ matrix.k8s_tag }} |
| 79 | + HELM_VERSION=${{ fromJson(needs.get_versions_job.outputs.latest_tools).helm_version }} |
| 80 | + KUSTOMIZE_VERSION=${{ fromJson(needs.get_versions_job.outputs.latest_tools).kustomize_version }} |
| 81 | + KUBESEAL_VERSION=${{ fromJson(needs.get_versions_job.outputs.latest_tools).kubeseal_version }} |
| 82 | + KREW_VERSION=${{ fromJson(needs.get_versions_job.outputs.latest_tools).krew_version }} |
| 83 | + VALS_VERSION=${{ fromJson(needs.get_versions_job.outputs.latest_tools).vals_version }} |
| 84 | + KUBECONFORM_VERSION=${{ fromJson(needs.get_versions_job.outputs.latest_tools).kubeconform_version }} |
0 commit comments