Add GitHub Actions workflow for building and pushing MCP Server Docker image (#656)
* Add GitHub Actions workflow for building and pushing MCP Server Docker image This commit introduces a new workflow that triggers on changes to the pyproject.toml file in the main branch. It builds and pushes the Docker image to Docker Hub, extracting the version from the pyproject.toml and setting up necessary permissions and steps for the process. * Add workflow_dispatch input to MCP Server Docker workflow This commit adds an optional input parameter, `push_image`, to the GitHub Actions workflow for the MCP Server Docker image. This allows users to control whether to push the image to the registry during manual workflow dispatch, enhancing flexibility for testing purposes. * Update Docker workflow conditions and increment version to 0.2.0 This commit modifies the MCP Server Docker workflow to include the `push_image` input conditionally for both pull requests and manual dispatches. Additionally, the version in `pyproject.toml` is updated from 0.1.0 to 0.2.0 to reflect the changes made. * Remove unnecessary package write permission from MCP Server Docker workflow * Add permissions for packages, actions, and security events in MCP Server Docker workflow * Update MCP Server Docker workflow to use Ubuntu 24.04 for build environment * Update MCP Server Docker workflow permissions to include id-token write access * Remove unused cache configuration from MCP Server Docker workflow
This commit is contained in:
parent
71360d91fc
commit
4652161c92
2 changed files with 74 additions and 1 deletions
73
.github/workflows/mcp-server-docker.yml
vendored
Normal file
73
.github/workflows/mcp-server-docker.yml
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
name: Build and Push MCP Server Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "mcp_server/pyproject.toml"
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
paths:
|
||||
- "mcp_server/pyproject.toml"
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
push_image:
|
||||
description: "Push image to registry (unchecked for testing)"
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
REGISTRY: docker.io
|
||||
IMAGE_NAME: zepai/knowledge-graph-mcp
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: depot-ubuntu-24.04-small
|
||||
environment: development
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Extract version from pyproject.toml
|
||||
id: version
|
||||
run: |
|
||||
VERSION=$(python -c "import tomllib; print(tomllib.load(open('mcp_server/pyproject.toml', 'rb'))['project']['version'])")
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || inputs.push_image)
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Set up Depot CLI
|
||||
uses: depot/setup-action@v1
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=raw,value=${{ steps.version.outputs.tag }}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Depot build and push image
|
||||
uses: depot/build-push-action@v1
|
||||
with:
|
||||
project: v9jv1mlpwc
|
||||
context: ./mcp_server
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || inputs.push_image) }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "mcp-server"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "Graphiti MCP Server"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10,<4"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue