Skip to content

Add MCP (Model Context Protocol) integration for enhanced research (#… #29

Add MCP (Model Context Protocol) integration for enhanced research (#…

Add MCP (Model Context Protocol) integration for enhanced research (#… #29

name: Build and Push Project Codespace Images
on:
push:
branches: [main]
paths-ignore:
- "_assets/**"
- ".github/**"
- ".gitignore"
- ".gitmodules"
- ".typos.toml"
- "CODE-OF-CONDUCT.md"
- "CONTRIBUTING.md"
- "scripts/**"
- "LICENSE"
- "pyproject.toml"
- "README.md"
workflow_dispatch:
inputs:
project:
description: "Project to build (leave empty to detect from changed files)"
required: false
default: ""
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Detect changed projects
id: set-matrix
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.project }}" ]]; then
PROJECTS="[\"${{ github.event.inputs.project }}\"]"
else
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
CHANGED_DIRS=$(echo "$CHANGED_FILES" \
| grep -o "^[^/]*" \
| sort -u \
| grep -v "^$")
ALL_PROJECT_DIRS=$(find . -maxdepth 1 -type d \
-not -path "*/\.*" \
-not -path "." \
| sed 's|^\./||' \
| grep -vE "^(scripts|_).*$")
PROJECTS="["
sep=""
for d in $CHANGED_DIRS; do
if echo "$ALL_PROJECT_DIRS" | grep -qx "$d"; then
PROJECTS+="${sep}\"$d\""
sep=","
fi
done
PROJECTS+="]"
fi
echo "matrix=$PROJECTS" >> $GITHUB_OUTPUT
echo "Projects to build: $PROJECTS"
build-or-generate:
needs: detect-changes
runs-on: ubuntu-latest
if: ${{ fromJson(needs.detect-changes.outputs.matrix)[0] != null }}
strategy:
matrix:
project: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check for Dockerfile.codespace
id: check
run: |
if [ -f "${{ matrix.project }}/Dockerfile.codespace" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
# ── Generate & submit PR if missing ─────────────────
- name: Generate Dockerfile.codespace
if: steps.check.outputs.exists == 'false'
run: python ./scripts/generate_codespace_dockerfile.py "${{ matrix.project }}"
- name: Create PR for generated Dockerfile
if: steps.check.outputs.exists == 'false'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Auto-generate Dockerfile.codespace for ${{ matrix.project }}"
title: "Auto-generate Dockerfile.codespace for ${{ matrix.project }}"
body: |
This PR adds a generated Dockerfile.codespace for ${{ matrix.project }}.
branch: "auto-dockerfile-${{ matrix.project }}"
base: main
labels: automated-pr,dockerfile,codespace
# ── Build & push if present ───────────────────
- name: Generate image tag timestamp
if: steps.check.outputs.exists == 'true'
id: timestamp
run: echo "timestamp=$(date -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: steps.check.outputs.exists == 'true'
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64
install: true
- name: Login to DockerHub
if: steps.check.outputs.exists == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: zenmldocker/projects-${{ matrix.project }}
tags: |
type=raw,value=latest
type=raw,value={{date 'YYYYMMDDHHmmss'}}
- name: Build and push Docker image
if: steps.check.outputs.exists == 'true'
uses: docker/build-push-action@v5
with:
context: ${{ matrix.project }}
file: ${{ matrix.project }}/Dockerfile.codespace
platforms: linux/amd64 # Force amd64 build
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}