From 7370b71271bda8c11ca447394f456419d04c816a Mon Sep 17 00:00:00 2001 From: norbjd Date: Sun, 24 Mar 2024 20:14:23 +0100 Subject: [PATCH] Release container images to ghcr.io (#28) --- .github/workflows/kind-e2e.yaml | 15 ++++++++++----- .github/workflows/release.yaml | 32 ++++++++++++++++++++++++++++++++ helm/values.yaml | 8 ++++---- 3 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/kind-e2e.yaml b/.github/workflows/kind-e2e.yaml index 50594a2..dd61e85 100644 --- a/.github/workflows/kind-e2e.yaml +++ b/.github/workflows/kind-e2e.yaml @@ -27,9 +27,6 @@ jobs: - ubuntu-22.04 # Ubuntu 22.04 uses cgroup v2 runs-on: ${{ matrix.os }} - env: - KO_DOCKER_REPO: kind.local - steps: - name: Set up Go 1.21.x uses: actions/setup-go@v4 @@ -55,9 +52,17 @@ jobs: curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash - name: Install k8s-pod-cpu-booster + env: + KO_DOCKER_REPO: kind.local run: | - KO_DOCKER_REPO=kind.local ko build -P ./cmd/informer ./cmd/webhook - helm install k8s-pod-cpu-booster --namespace pod-cpu-booster --create-namespace ./helm + INFORMER_IMAGE=$(ko build ./cmd/informer) + WEBHOOK_IMAGE=$(ko build ./cmd/webhook) + + helm install k8s-pod-cpu-booster --namespace pod-cpu-booster --create-namespace ./helm \ + --set informer.image=$INFORMER_IMAGE \ + --set informer.imagePullPolicy=Never \ + --set webhook.image=$WEBHOOK_IMAGE \ + --set webhook.imagePullPolicy=Never - name: Wait for Ready run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..fec2da1 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,32 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + release: + name: build and push to ghcr.io + runs-on: ubuntu-22.04 + permissions: + packages: write + + steps: + - uses: actions/setup-go@v4 + with: + go-version: 1.21.x + - uses: ko-build/setup-ko@v0.6 + - uses: actions/checkout@v4 + + - name: Build and push + env: + KO_DOCKER_REPO: ghcr.io/norbjd/k8s-pod-cpu-booster + run: | + # something like 202403241909-abcdef01 if we want to use a specific version + UNIQUE_TAG="$(TZ=UTC0 git log -1 --format=%cd --date=format-local:%Y%m%d%H%M)-$(git rev-parse --short HEAD)" + + ko build ./cmd/informer ./cmd/webhook \ + --base-import-paths \ + --sbom=none \ + --tags=$GITHUB_REF_NAME,$UNIQUE_TAG diff --git a/helm/values.yaml b/helm/values.yaml index f9a7c8b..35af89e 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -3,12 +3,12 @@ nameOverride: "" fullnameOverride: "" informer: - image: kind.local/github.com/norbjd/k8s-pod-cpu-booster/cmd/informer:latest - imagePullPolicy: Never + image: ghcr.io/norbjd/k8s-pod-cpu-booster/informer:main + imagePullPolicy: Always resources: {} webhook: - image: kind.local/github.com/norbjd/k8s-pod-cpu-booster/cmd/webhook:latest - imagePullPolicy: Never + image: ghcr.io/norbjd/k8s-pod-cpu-booster/webhook:main + imagePullPolicy: Always replicaCount: 3 resources: {}