Skip to content

Commit 90f3d43

Browse files
committed
infra: Roll pods on infra deploys
1 parent c733ced commit 90f3d43

File tree

3 files changed

+60
-47
lines changed

3 files changed

+60
-47
lines changed

.github/workflows/deploy.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,52 @@ env:
1010
GO_VERSION: "1.24.6"
1111

1212
jobs:
13+
docker-push:
14+
name: Build Docker Image
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log in to Container Registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ghcr.io/${{ github.repository }}
38+
tags: |
39+
type=raw,value=latest,enable={{is_default_branch}}
40+
type=sha,prefix=main-{{date 'YYYYMMDD'}}-,enable={{is_default_branch}}
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
file: ./Dockerfile
47+
platforms: linux/amd64,linux/arm64
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
cache-from: type=gha
52+
cache-to: type=gha,mode=max
53+
1354
deploy-staging:
1455
name: Deploy to Staging
1556
runs-on: ubuntu-latest
1657
environment: staging
58+
needs: docker-build
1759
steps:
1860
- name: Checkout code
1961
uses: actions/checkout@v4

.github/workflows/docker.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

deploy/pkg/k8s/registry.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package k8s
22

33
import (
4+
"os/exec"
5+
"strings"
6+
47
v1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/apps/v1"
58
corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1"
69
metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/meta/v1"
@@ -11,6 +14,17 @@ import (
1114
"github.com/modelcontextprotocol/registry/deploy/infra/pkg/providers"
1215
)
1316

17+
// getGitCommitHash returns the current git commit hash
18+
func getGitCommitHash() string {
19+
cmd := exec.Command("git", "rev-parse", "HEAD")
20+
output, err := cmd.Output()
21+
if err != nil {
22+
// Fallback to a default value if git command fails
23+
return "unknown"
24+
}
25+
return strings.TrimSpace(string(output))
26+
}
27+
1428
// DeployMCPRegistry deploys the MCP Registry to the Kubernetes cluster
1529
func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, environment string) (*corev1.Service, error) {
1630
conf := config.New(ctx, "mcp-registry")
@@ -58,6 +72,10 @@ func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, env
5872
Labels: pulumi.StringMap{
5973
"app": pulumi.String("mcp-registry"),
6074
},
75+
Annotations: pulumi.StringMap{
76+
// Use git commit hash to trigger pod restarts when deploying new infra versions
77+
"registry.modelcontextprotocol.io/deployCommit": pulumi.String(getGitCommitHash()),
78+
},
6179
},
6280
Spec: &corev1.PodSpecArgs{
6381
Containers: corev1.ContainerArray{

0 commit comments

Comments
 (0)