Skip to content

Commit d25ab9b

Browse files
committed
ci: add publish workflow for controller
This commit adds a GHA workflow to support publishing a container image for the `workspaces/controller` component as well as some updates to the `Makefile` to establish reasonable (but overridable) defaults. Key behavior: - Publishes controller images on any workspaces/ directory change - Builds images with commit SHA tags by default - "release" images with use the tag as defined by the `VERSION` file - a `-dirty` suffix is added to the tag if the codebase is not `porcelain` - no `latest` tag is ever produced on images - Uses `ghcr.io/kubeflow/notebooks` registry with configurable naming example image name from "random" commit: - `ghcr.io/kubeflow/notebooks/workspaces-controller:sha-3fa851ab3173942dbaa1a609468e7f9eadf5f4e4` example image name from release: - `ghcr.io/kubeflow/notebooks/workspaces-controller:v2.0.0` Signed-off-by: Andy Stoneberg <astonebe@redhat.com>
1 parent 68d9466 commit d25ab9b

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build & Publish Controller container image
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- notebooks-v2
7+
- v*-branch
8+
paths:
9+
- workspaces/** ## NOTE: we publish changes on any commit to workspaces/ components
10+
- releasing/version/VERSION
11+
12+
env:
13+
REGISTRY: ghcr.io/kubeflow/notebooks
14+
NAME: workspaces-controller
15+
16+
jobs:
17+
push_to_registry:
18+
name: Build & Push container image to GHCR
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- uses: dorny/paths-filter@v3
25+
id: filter
26+
with:
27+
base: ${{ github.ref }}
28+
filters: |
29+
version:
30+
- 'releasing/version/VERSION'
31+
32+
- name: Login to GHCR
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Setup QEMU
40+
uses: docker/setup-qemu-action@v3
41+
42+
- name: Setup Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Build and push multi-arch container image
46+
run: |
47+
cd workspaces/controller
48+
make docker-buildx REGISTRY=${REGISTRY} NAME=${NAME}
49+
50+
- name: Build and push multi-arch container image on Version change
51+
id: version
52+
if: steps.filter.outputs.version == 'true'
53+
run: |
54+
VERSION=$(cat releasing/version/VERSION)
55+
cd workspaces/controller
56+
make docker-buildx REGISTRY=${REGISTRY} NAME=${NAME} TAG=${VERSION}

releasing/version/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
latest

workspaces/controller/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
GIT_COMMIT := $(shell git rev-parse HEAD)
2+
GIT_TREE_STATE := $(shell test -n "`git status --porcelain`" && echo "-dirty" || echo "")
3+
14
# Image URL to use all building/pushing image targets
2-
TAG ?= $(shell git describe --tags --always --dirty)
3-
IMG ?= ghcr.io/kubeflow/notebooks/workspaces-controller:$(TAG)
5+
REGISTRY ?= ghcr.io/kubeflow/notebooks
6+
NAME ?= workspaces-controller
7+
TAG ?= sha-$(GIT_COMMIT)$(GIT_TREE_STATE)
8+
IMG ?= $(REGISTRY)/$(NAME):$(TAG)
49

510

611
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.

0 commit comments

Comments
 (0)