Skip to content

Commit 8cc29a2

Browse files
committed
ci: improve github workflows
1 parent cc8a4fa commit 8cc29a2

File tree

3 files changed

+63
-31
lines changed

3 files changed

+63
-31
lines changed

.github/workflows/cd.yaml

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ name: Publish to container registries
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- src/**
12+
- Dockerfile
13+
- pyproject.toml
14+
pull_request:
15+
paths:
16+
- src/**
17+
- Dockerfile
18+
- pyproject.toml
619

720
jobs:
821
docker-hub:
@@ -20,8 +33,23 @@ jobs:
2033
- name: Set up Docker Buildx
2134
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca #v3.9.0
2235

36+
- name: Extract tags and labels for Docker
37+
id: meta
38+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
39+
with:
40+
images: ${{ github.repository }}
41+
tags: |
42+
type=sha,format=short,prefix=commit-
43+
type=ref,event=tag
44+
labels: |
45+
maintainer="Sergey Parfenyuk"
46+
org.opencontainers.image.source=https://github.com/sparfenyuk/mcp-proxy
47+
org.opencontainers.image.description="Connect to MCP servers that run on SSE transport, or expose stdio servers as an SSE server using the MCP Proxy server."
48+
org.opencontainers.image.licenses=MIT
49+
2350
- name: Log in to Docker Hub
2451
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
52+
if: github.event_name != 'pull_request'
2553
with:
2654
username: ${{ secrets.DOCKER_USERNAME }}
2755
password: ${{ secrets.DOCKER_PASSWORD }}
@@ -31,11 +59,17 @@ jobs:
3159
with:
3260
context: .
3361
platforms: linux/amd64,linux/arm64
34-
push: true
35-
tags: "${{ github.repository }}:${{ github.event.release.tag_name }}-alpine"
62+
push: ${{ github.event_name != 'pull_request' }}
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
annotations: ${{ steps.meta.outputs.annotations }}
3666
cache-from: type=gha
3767
cache-to: type=gha,mode=max
38-
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Connect to MCP servers that run on SSE transport, or expose stdio servers as an SSE server using the MCP Proxy server.
68+
69+
- name: Clean Docker cache
70+
if: github.event_name != 'pull_request'
71+
run: |
72+
docker system prune --force
3973
4074
ghcr-io:
4175
name: Push multi-arch Docker image to ghcr.io
@@ -53,8 +87,23 @@ jobs:
5387
- name: Set up Docker Buildx
5488
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca #v3.9.0
5589

90+
- name: Extract tags and labels for Docker
91+
id: meta
92+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
93+
with:
94+
images: ghcr.io/${{ github.repository }}
95+
tags: |
96+
type=sha,format=short,prefix=commit-
97+
type=ref,event=tag
98+
labels: |
99+
maintainer="Sergey Parfenyuk"
100+
org.opencontainers.image.source=https://github.com/sparfenyuk/mcp-proxy
101+
org.opencontainers.image.description="Connect to MCP servers that run on SSE transport, or expose stdio servers as an SSE server using the MCP Proxy server."
102+
org.opencontainers.image.licenses=MIT
103+
56104
- name: Log in to GHCR
57105
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
106+
if: github.event_name != 'pull_request'
58107
with:
59108
registry: ghcr.io
60109
username: ${{ github.actor }}
@@ -65,7 +114,14 @@ jobs:
65114
with:
66115
context: .
67116
platforms: linux/amd64,linux/arm64
68-
push: true
69-
tags: "ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }}-alpine"
117+
push: ${{ github.event_name != 'pull_request' }}
118+
tags: ${{ steps.meta.outputs.tags }}
119+
labels: ${{ steps.meta.outputs.labels }}
120+
annotations: ${{ steps.meta.outputs.annotations }}
70121
cache-from: type=gha
71122
cache-to: type=gha,mode=max
123+
124+
- name: Clean Docker cache
125+
if: github.event_name != 'pull_request'
126+
run: |
127+
docker system prune --force

.github/workflows/ci.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,6 @@ jobs:
107107

108108
- run: uv run --frozen coverage report --fail-under 83
109109

110-
docker:
111-
runs-on: ubuntu-latest
112-
needs: [lint, coverage, mypy]
113-
steps:
114-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
115-
116-
- name: Set up QEMU
117-
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 #v3.4.0
118-
119-
- name: Set up Docker Buildx
120-
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca #v3.9.0
121-
122-
- name: Build Docker image
123-
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
124-
with:
125-
context: .
126-
platforms: linux/amd64,linux/arm64
127-
push: false
128-
tags: "${{ github.repository }}:devel"
129-
130110
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
131111
check:
132112
if: always()

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage with explicit platform specification
2-
FROM --platform=$TARGETPLATFORM ghcr.io/astral-sh/uv:python3.12-alpine AS uv
2+
FROM ghcr.io/astral-sh/uv:python3.12-alpine AS uv
33

44
# Install the project into /app
55
WORKDIR /app
@@ -23,11 +23,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
2323
uv sync --frozen --no-dev --no-editable
2424

2525
# Final stage with explicit platform specification
26-
FROM --platform=$TARGETPLATFORM python:3.12-alpine
27-
28-
LABEL org.opencontainers.image.source=https://github.com/sparfenyuk/mcp-proxy
29-
LABEL org.opencontainers.image.description="Connect to MCP servers that run on SSE transport, or expose stdio servers as an SSE server using the MCP Proxy server."
30-
LABEL org.opencontainers.image.licenses=MIT
26+
FROM python:3.12-alpine
3127

3228
COPY --from=uv --chown=app:app /app/.venv /app/.venv
3329

0 commit comments

Comments
 (0)