Skip to content

Publish Karpenter Image #40

Publish Karpenter Image

Publish Karpenter Image #40

name: Publish Karpenter Image
on:
push:
branches:
- main
paths:
- 'karpenter/**'
- 'plugin/**'
tags:
- 'karpenter/v*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/karpenter
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: karpenter/go.mod
cache-dependency-path: karpenter/go.sum
- name: Vendor and apply patches
working-directory: karpenter
run: make vendor-patch
- name: Build binaries
working-directory: karpenter
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=vendor -trimpath -o bin/controller-linux-amd64 ./cmd/controller
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -mod=vendor -trimpath -o bin/controller-linux-arm64 ./cmd/controller
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,prefix=sha-,format=short
type=match,pattern=karpenter/v(.*),group=1
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/karpenter/v') }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: karpenter
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}