-
Notifications
You must be signed in to change notification settings - Fork 20
120 lines (104 loc) · 3.91 KB
/
publish-docker.yml
File metadata and controls
120 lines (104 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Publish Docker Image
on:
release:
types: [published]
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
publish:
name: Build and Publish Multi-Arch Docker Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/gleanwork/local-mcp-server
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=branch
type=sha,prefix=,enable=${{ github.event_name == 'push' && github.ref_type == 'branch' }}
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.title=Glean MCP Server
org.opencontainers.image.description=Model Context Protocol server for Glean API integration
org.opencontainers.image.vendor=Glean
- name: Build and push multi-architecture image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
verify-public-access:
name: Verify Anonymous GHCR Pull Access
runs-on: ubuntu-latest
needs: publish
if: needs.publish.result == 'success'
timeout-minutes: 10
steps:
- name: Verify anonymous manifest access (with retry)
run: |
set -euo pipefail
image="ghcr.io/gleanwork/local-mcp-server:latest"
attempts=18
sleep_seconds=10
success=0
for attempt in $(seq 1 "${attempts}"); do
if docker manifest inspect "${image}" >/dev/null 2>&1; then
success=1
echo "Anonymous manifest access verified for ${image}"
break
fi
echo "Attempt ${attempt}/${attempts}: ${image} not anonymously available yet"
sleep "${sleep_seconds}"
done
if [[ "${success}" -ne 1 ]]; then
echo "::error title=Anonymous GHCR pull failed::Unable to pull ${image} without authentication. Set GitHub Packages visibility to Public for ghcr.io/gleanwork/local-mcp-server."
exit 1
fi
- name: Pull and smoke test image anonymously
run: |
set -euo pipefail
image="ghcr.io/gleanwork/local-mcp-server:latest"
docker pull "${image}"
docker run --rm --entrypoint node "${image}" --version
init_payload='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"gh-actions","version":"1.0"}}}'
printf '%s\n' "${init_payload}" | docker run --rm -i "${image}" > /tmp/mcp-init.txt 2>&1 &
docker_pid=$!
sleep 3
if kill -0 "${docker_pid}" 2>/dev/null; then
kill "${docker_pid}" 2>/dev/null || true
wait "${docker_pid}" 2>/dev/null || true
fi
if grep -q '"result"' /tmp/mcp-init.txt; then
echo "MCP initialize handshake succeeded"
else
echo "::error title=Docker runtime smoke test failed::MCP initialize response missing from container output"
cat /tmp/mcp-init.txt
exit 1
fi