Skip to content

Commit 903d2d7

Browse files
Merge pull request #1236 from kubeflow/main
[pull] main from kubeflow:main
2 parents 5d76ddb + f0d58aa commit 903d2d7

File tree

14 files changed

+966
-228
lines changed

14 files changed

+966
-228
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Controller container image build and tag
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
tags:
7+
- 'v*'
8+
paths-ignore:
9+
- 'LICENSE*'
10+
- '**.gitignore'
11+
- '**.md'
12+
- '**.txt'
13+
- '.github/ISSUE_TEMPLATE/**'
14+
- '.github/dependabot.yml'
15+
- 'docs/**'
16+
permissions: # set contents: read at top-level, per OpenSSF ScoreCard rule TokenPermissionsID\
17+
contents: read
18+
env:
19+
IMG_REGISTRY: ghcr.io
20+
IMG_ORG: kubeflow
21+
IMG_REPO: model-registry/controller
22+
PUSH_IMAGE: true
23+
DOCKER_USER: ${{ github.actor }}
24+
DOCKER_PWD: ${{ secrets.GITHUB_TOKEN }}
25+
PLATFORMS: linux/arm64,linux/amd64
26+
jobs:
27+
build-controller-image:
28+
runs-on: ubuntu-latest
29+
permissions:
30+
actions: read # anchore/sbom-action for syft
31+
contents: write # anchore/sbom-action for syft
32+
packages: write
33+
id-token: write # cosign
34+
steps:
35+
# Assign context variable for various action contexts (tag, main, CI)
36+
- name: Assigning tag context
37+
if: github.head_ref == '' && startsWith(github.ref, 'refs/tags/v')
38+
run: echo "BUILD_CONTEXT=tag" >> $GITHUB_ENV
39+
- name: Assigning main context
40+
if: github.head_ref == '' && github.ref == 'refs/heads/main'
41+
run: echo "BUILD_CONTEXT=main" >> $GITHUB_ENV
42+
# checkout branch
43+
- uses: actions/checkout@v6.0.1
44+
- name: Set up QEMU
45+
uses: docker/setup-qemu-action@v3
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
# set image version
49+
- name: Set main-branch environment
50+
if: env.BUILD_CONTEXT == 'main'
51+
run: |
52+
commit_sha=${{ github.event.after }}
53+
tag=main-${commit_sha:0:7}
54+
echo "VERSION=${tag}" >> $GITHUB_ENV
55+
- name: Set tag environment
56+
if: env.BUILD_CONTEXT == 'tag'
57+
run: |
58+
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
59+
# docker login
60+
- name: Log in to the Container registry
61+
uses: docker/login-action@v3
62+
with:
63+
registry: ${{ env.IMG_REGISTRY }}
64+
username: ${{ env.DOCKER_USER }}
65+
password: ${{ env.DOCKER_PWD }}
66+
- name: Extract metadata (tags, labels) for Docker
67+
id: meta
68+
uses: docker/metadata-action@v5
69+
with:
70+
images: "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_REPO }}"
71+
tags: |
72+
type=raw,value=${{ env.VERSION }}
73+
type=raw,value=latest,enable=${{ env.BUILD_CONTEXT == 'main' }}
74+
type=raw,value=main,enable=${{ env.BUILD_CONTEXT == 'main' }}
75+
- name: Build and push Docker image
76+
id: build-push
77+
uses: docker/build-push-action@v6
78+
with:
79+
context: .
80+
file: ./cmd/controller/Dockerfile.controller
81+
platforms: ${{ env.PLATFORMS }}
82+
push: true
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}
85+
cache-from: type=gha
86+
cache-to: type=gha,mode=max
87+
provenance: mode=max
88+
- name: Install Cosign
89+
uses: sigstore/cosign-installer@v3
90+
- name: Sign image with cosign
91+
run: |
92+
cosign sign --yes "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_REPO }}@${{ steps.build-push.outputs.digest }}"
93+
- name: Generate SBOM
94+
uses: anchore/sbom-action@v0
95+
with:
96+
image: "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_REPO }}@${{ steps.build-push.outputs.digest }}"
97+
format: spdx-json # default, but making sure of the format
98+
artifact-name: "controller-${{ env.VERSION }}-sbom.spdx.json"
99+
output-file: "controller-${{ env.VERSION }}-sbom.spdx.json" # pin the file to use it later below
100+
- name: Attest SBOM to image
101+
run: |
102+
cosign attest --yes --predicate controller-${{ env.VERSION }}-sbom.spdx.json --type spdxjson "${{ env.IMG_REGISTRY }}/${{ env.IMG_ORG }}/${{ env.IMG_REPO }}@${{ steps.build-push.outputs.digest }}"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ clean/odh:
169169
rm -Rf ./model-registry
170170

171171
bin/envtest:
172-
GOBIN=$(PROJECT_BIN) ${GO} install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.21
172+
GOBIN=$(PROJECT_BIN) ${GO} install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.23
173173

174174
GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint
175175
bin/golangci-lint:

0 commit comments

Comments
 (0)