mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-19 18:16:09 +00:00
chore: testing splitting job across runners
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
This commit is contained in:
113
.github/workflows/build_container.yaml
vendored
113
.github/workflows/build_container.yaml
vendored
@@ -16,6 +16,8 @@ on:
|
|||||||
env:
|
env:
|
||||||
GO_VERSION: "~1.22"
|
GO_VERSION: "~1.22"
|
||||||
IMAGE_NAME: "k8sgpt"
|
IMAGE_NAME: "k8sgpt"
|
||||||
|
REGISTRY_IMAGE: ghcr.io/k8sgpt-ai/k8sgpt
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -54,26 +56,89 @@ jobs:
|
|||||||
NON_FORKED_AND_NON_ROBOT_RUN=${{ ( github.actor != 'renovate[bot]' && github.actor != 'dependabot[bot]' ) && ( github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository ) }}
|
NON_FORKED_AND_NON_ROBOT_RUN=${{ ( github.actor != 'renovate[bot]' && github.actor != 'dependabot[bot]' ) && ( github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository ) }}
|
||||||
echo "NON_FORKED_AND_NON_ROBOT_RUN=$NON_FORKED_AND_NON_ROBOT_RUN" >> "$GITHUB_OUTPUT"
|
echo "NON_FORKED_AND_NON_ROBOT_RUN=$NON_FORKED_AND_NON_ROBOT_RUN" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
upload_images:
|
build:
|
||||||
name: Upload images to ghcr registry
|
name: Build for ${{ matrix.platform }}
|
||||||
needs: prepare_ci_run
|
needs: prepare_ci_run
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
image:
|
platform:
|
||||||
- name: k8sgpt
|
- linux/amd64
|
||||||
target: production
|
- linux/arm64
|
||||||
env:
|
env:
|
||||||
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
|
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
|
||||||
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
|
BUILD_TIME: ${{ needs.prepare_ci_run.outputs.BUILD_TIME }}
|
||||||
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
|
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }}
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set env pair
|
||||||
|
run: |
|
||||||
|
platform=${{ matrix.platform }}
|
||||||
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./container/Dockerfile
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
target: production
|
||||||
|
build-args: |
|
||||||
|
GIT_HASH=${{ env.GIT_SHA }}
|
||||||
|
RELEASE_VERSION=dev-${{ env.DATETIME }}
|
||||||
|
BUILD_TIME=${{ env.BUILD_TIME }}
|
||||||
|
tags: ${{ env.REGISTRY_IMAGE }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
|
||||||
|
|
||||||
|
- name: Export digest
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ runner.temp }}/digests
|
||||||
|
echo "${{ steps.build.outputs.digest }}" > "${{ runner.temp }}/digests/${{ env.PLATFORM_PAIR }}.digest"
|
||||||
|
|
||||||
|
- name: Upload digest
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
|
path: ${{ runner.temp }}/digests/*
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
merge:
|
||||||
|
name: Create and Push Manifest List
|
||||||
|
needs: build
|
||||||
|
# if: github.event_name == 'push' && needs.prepare_ci_run.outputs.NON_FORKED_AND_NON_ROBOT_RUN == 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download digests
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ${{ runner.temp }}/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
@@ -82,23 +147,21 @@ jobs:
|
|||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Docker meta
|
||||||
uses: docker/build-push-action@v6
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
file: ./container/Dockerfile
|
|
||||||
platforms: linux/arm64
|
|
||||||
target: ${{ matrix.image.target }}
|
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/k8sgpt-ai/${{ matrix.image.name }}:dev-${{ env.DATETIME }}
|
type=ref,event=branch
|
||||||
build-args: |
|
type=ref,event=pr
|
||||||
GIT_HASH=${{ env.GIT_SHA }}
|
type=semver,pattern={{version}}
|
||||||
RELEASE_VERSION=dev-${{ env.DATETIME }}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
BUILD_TIME=${{ env.BUILD_TIME }}
|
type=raw,value=dev-${{ needs.prepare_ci_run.outputs.DATETIME }}
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
|
||||||
push: true
|
- name: Create manifest list and push
|
||||||
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.image.name }}
|
working-directory: ${{ runner.temp }}/digests
|
||||||
cache-to: type=gha,scope=${{ github.ref_name }}-${{ matrix.image.name }}
|
run: |
|
||||||
|
digests=$(printf "${{ env.REGISTRY_IMAGE }}@%s " $(cat *.*_
|
||||||
|
Reference in New Issue
Block a user