Skip to content

Commit

Permalink
sign kurator images
Browse files Browse the repository at this point in the history
Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
  • Loading branch information
LiZhenCheng9527 committed Jan 27, 2024
1 parent 4d616a0 commit 853543c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/release-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:

jobs:
build-push:
permissions:
id-token: write # To be able to get OIDC ID token to sign images.
runs-on: ubuntu-latest
steps:
- name: Get image version
Expand All @@ -21,12 +23,24 @@ jobs:
with:
go-version: 1.20.x

- name: Install Cosign
uses: sigstore/cosign-installer@v3.0.3
with:
cosign-release: 'v1.13.1'

- name: Compile
run: make build

- name: Build Docker Image
run: VERSION=${{ env.image_version }} make docker

- name: Sign Image
env:
VERSION: ${{ env.image_version }}
COSIGN_EXPERIMENTAL: 1
SIGN_IMAGE: 1
run: make sign-image

- name: Login to ghcr.io
# This is where you will update the PAT to GITHUB_TOKEN
run: echo "${{ secrets.GH_PAT }}" | docker login ghcr.io -u $ --password-stdin
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ docker-push: docker
docker push ${IMAGE_HUB}/cluster-operator:${IMAGE_TAG}
docker push ${IMAGE_HUB}/fleet-manager:${IMAGE_TAG}

.PHONY: sign-image
sign-image:
./hack/image-sign.sh

.PHONY: lint
lint: golangci-lint lint-copyright lint-markdown lint-shellcheck

Expand Down
18 changes: 18 additions & 0 deletions hack/image-sign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

IMAGE_HUB=${IMAGE_HUB:-"ghcr.io/kurator-dev"}
IMAGE_TAG=${VERSION:-"$(VERSION)"}
SIGN_IMAGE=${SIGN_IMAGE:-"0"}

CLUSTER_OPERATOR_IMAGE=${CLUSTER_OPERATOR_IMAGE:-"${IMAGE_HUB}/cluster-operator:${IMAGE_TAG}"}
FLEET_MANAGER_IMAGE=${FLEET_MANAGER_IMAGE:-"${IMAGE_HUB}/fleet-manager:${IMAGE_TAG}"}

if [ $SIGN_IMAGE = "1" ]; then
echo "Sign image: "${CLUSTER_OPERATOR_IMAGE}
cosign sign --yes ${CLUSTER_OPERATOR_IMAGE}
echo "Sign image: "${FLEET_MANAGER_IMAGE}
cosign sign --yes ${FLEET_MANAGER_IMAGE}
else
echo "Warning: The build image is not signed"
fi

0 comments on commit 853543c

Please sign in to comment.