From 4652161c92df13af62953ce50f90887a40e80ac3 Mon Sep 17 00:00:00 2001 From: Daniel Chalef <131175+danielchalef@users.noreply.github.com> Date: Tue, 1 Jul 2025 15:55:08 -0700 Subject: [PATCH] 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 --- .github/workflows/mcp-server-docker.yml | 73 +++++++++++++++++++++++++ mcp_server/pyproject.toml | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/mcp-server-docker.yml diff --git a/.github/workflows/mcp-server-docker.yml b/.github/workflows/mcp-server-docker.yml new file mode 100644 index 00000000..67002d1a --- /dev/null +++ b/.github/workflows/mcp-server-docker.yml @@ -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 }} diff --git a/mcp_server/pyproject.toml b/mcp_server/pyproject.toml index 91e98f85..d6b9a3fc 100644 --- a/mcp_server/pyproject.toml +++ b/mcp_server/pyproject.toml @@ -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"