Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
go build -v -ldflags="-X github.com/Azure/mcp-kubernetes/internal/version.GitCommit=$(git rev-parse HEAD) -X github.com/Azure/mcp-kubernetes/internal/version.BuildMetadata=$(date +%Y%m%d)" -o mcp-kubernetes ./cmd/mcp-kubernetes

- name: Build Docker image
run: docker build -t mcp-kubernetes:test .
run: docker build -t mcp-kubernetes:test --build-arg VERSION=$(git describe --tags --always --dirty | cut -c2-),GIT_COMMIT=$(git rev-parse HEAD),BUILD_DATE=$(date +%Y%m%d),GIT_TREE_STATE=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi) .

- name: Check Docker image
run: |
Expand Down
70 changes: 68 additions & 2 deletions .github/workflows/go-ossf-slsa3-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
# The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier.
# For more information about SLSA and how it improves the supply-chain, visit slsa.dev.

name: SLSA Go releaser
name: SLSA releaser
on:
workflow_dispatch:
push:
tags:
- "v*"

permissions: read-all

env:
IMAGE_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# Generate ldflags dynamically.
# Optional: only needed for ldflags.
Expand Down Expand Up @@ -66,3 +68,67 @@ jobs:
# Optional: For more options, see https://github.com/slsa-framework/slsa-github-generator#golang-projects
# =============================================================================================================

build-image:
permissions:
contents: read
packages: write
needs: args
outputs:
image: ${{ steps.image.outputs.image }}
digest: ${{ steps.build.outputs.digest }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2.3.4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0

- name: Authenticate Docker
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # v4.0.1
with:
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # v3.0.0
id: build
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ needs.args.outputs.version }}
GIT_COMMIT=${{ needs.args.outputs.commit }}
BUILD_DATE=${{ needs.args.outputs.commit-date }}
GIT_TREE_STATE=${{ needs.args.outputs.tree-state }}
- name: Output image
id: image
run: |
# NOTE: Set the image as an output because the `env` context is not
# available to the inputs of a reusable workflow call.
image_name=$(echo "${IMAGE_REGISTRY}/${IMAGE_NAME}"| tr '[:upper:]' '[:lower:]')
echo "image=$image_name" >> "$GITHUB_OUTPUT"
# This step calls the container workflow to generate provenance and push it to
# the container registry.
provenance:
needs: build-image
permissions:
actions: read # for detecting the Github Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0
with:
image: ${{ needs.build-image.outputs.image }}
digest: ${{ needs.build-image.outputs.digest }}
registry-username: ${{ github.actor }}
private-repository: true
secrets:
registry-password: ${{ secrets.GITHUB_TOKEN }}
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Build stage
FROM golang:1.24-alpine AS builder

ARG VERSION
ARG GIT_COMMIT
ARG BUILD_DATE
ARG GIT_TREE_STATE
# Set working directory
WORKDIR /app

Expand All @@ -14,7 +17,7 @@ RUN go mod download
COPY . .

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/Azure/mcp-kubernetes/internal/version.GitCommit=$(git rev-parse HEAD 2>/dev/null || echo 'unknown') -X github.com/Azure/mcp-kubernetes/internal/version.BuildMetadata=$(date +%Y%m%d)" -o mcp-kubernetes ./cmd/mcp-kubernetes
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/Azure/mcp-kubernetes/internal/version.GitVersion=${VERSION} -X github.com/Azure/mcp-kubernetes/internal/version.GitCommit=${GIT_COMMIT} -X github.com/Azure/mcp-kubernetes/internal/version.BuildMetadata=${BUILD_DATE} -X github.com/Azure/mcp-kubernetes/internal/version.GitTreeState=${GIT_TREE_STATE}" -o mcp-kubernetes ./cmd/mcp-kubernetes

# Runtime stage
FROM alpine:3.19
Expand Down
Loading