Skip to main content
Complete guide for setting up and configuring GitHub Actions for the MCP Server with LangGraph.

Table of Contents

Overview

This repository includes comprehensive GitHub Actions workflows for:
  • CI/CD Pipeline (ci.yaml) - Test, build, and deploy
  • Pull Request Checks (pr-checks.yaml) - Automated PR validation
  • Security Scanning (security-scan.yaml) - Daily security scans
  • Release Automation (release.yaml) - Automated releases
  • Stale Issues (stale.yaml) - Issue/PR management

Required Secrets

GitHub Repository Secrets

Navigate to: Settings → Secrets and variables → Actions
Application Secrets
Infrastructure Secrets (Optional)
Container Registry
GitHub Container Registry (ghcr.io) uses GITHUB_TOKEN automatically - no setup needed.

Environment Secrets

For deployment environments: Settings → Environments
Development Environment
Create environment: development Secrets:
  • KUBECONFIG_DEV
  • ANTHROPIC_API_KEY
  • JWT_SECRET_KEY
  • OPENFGA_STORE_ID
  • OPENFGA_MODEL_ID
Protection rules: None (auto-deploy)
Staging Environment
Create environment: staging Secrets:
  • KUBECONFIG_STAGING
  • ANTHROPIC_API_KEY
  • JWT_SECRET_KEY
  • OPENFGA_STORE_ID
  • OPENFGA_MODEL_ID
Protection rules:
  • Required reviewers: 1
  • Deployment branches: main only
Production Environment
Create environment: production Secrets:
  • KUBECONFIG_PROD
  • ANTHROPIC_API_KEY
  • JWT_SECRET_KEY
  • OPENFGA_STORE_ID
  • OPENFGA_MODEL_ID
Protection rules:
  • Required reviewers: 2+ (security team)
  • Deployment branches: Tags only (v*.*.*)
  • Wait timer: 5 minutes

Workflows

1. CI/CD Pipeline (ci.yaml)

Triggers:
  • Push to main or develop
  • Pull requests to main
  • Release creation
Jobs:
  1. Test - Run unit and integration tests
  2. Lint - Code quality checks
  3. Build - Docker image build and push
  4. Deploy Dev - Auto-deploy to development (on develop)
  5. Deploy Staging - Auto-deploy to staging (on main)
  6. Deploy Prod - Manual deploy to production (on release)
Badge:

2. Pull Request Checks (pr-checks.yaml)

Triggers:
  • Pull request opened/updated/reopened
Jobs:
  1. PR Metadata - Validate PR title (Conventional Commits)
  2. Test Matrix - Test on Python 3.10, 3.11, 3.12
  3. Lint - Code quality and formatting
  4. Security - Security scans
  5. Docker - Build test
  6. Size Check - Large file detection
  7. Dependency Review - Scan for vulnerable dependencies
  8. Auto Label - Apply labels based on changed files
  9. Comment - Post check results
Setup:

3. Security Scan (security-scan.yaml)

Triggers:
  • Daily at 2 AM UTC
  • Push to main
  • Pull requests
  • Manual dispatch
Jobs:
  1. Trivy - Container vulnerability scanning
  2. Dependency Check - Python package vulnerabilities
  3. CodeQL - Static code analysis
  4. Secrets Scan - TruffleHog secrets detection
  5. License Check - License compliance
Required:
  • Enable CodeQL in repository settings
  • Configure Security tab for SARIF uploads

4. Release Automation (release.yaml)

Triggers:
  • Git tags matching v*.*.*
Jobs:
  1. Create Release - Generate changelog and GitHub release
  2. Build Images - Multi-arch Docker images (amd64, arm64)
  3. Publish Helm - Push Helm chart to OCI registry
  4. Publish PyPI - Publish Python package (stable only)
  5. Update MCP Registry - Update MCP registry entry
  6. Notify - Send Slack notifications
Usage:

5. Quality Tests (quality-tests.yaml)

Triggers:
  • Pull requests to main
  • Push to main
  • Weekly schedule (Sunday at midnight)
  • Manual dispatch
Jobs:
  1. Property Tests - Hypothesis-based edge case discovery (27+ tests)
  2. Contract Tests - MCP protocol compliance validation (20+ tests)
  3. Regression Tests - Performance baseline tracking
  4. Benchmark Tests - Performance monitoring with alerts
  5. Mutation Tests - Test effectiveness measurement (weekly only)
  6. Quality Summary - Aggregate results reporting
Badge:

6. Stale Issue Management (stale.yaml)

Triggers:
  • Daily at midnight
Configuration:
  • Issues: 60 days inactive → stale, 7 days → close
  • PRs: 30 days inactive → stale, 7 days → close
  • Exempt labels: pinned, security, bug, critical

Branch Protection

Main Branch Protection

Navigate to: Settings → Branches → Branch protection rules Create rule for main:

Develop Branch Protection

Create rule for develop:

Environment Configuration

Setting Up Kubeconfig

Testing Secrets Locally

Codecov Integration

Setup Codecov

  1. Sign up at https://codecov.io with GitHub
  2. Enable repository in Codecov dashboard
  3. Get upload token (optional - GITHUB_TOKEN works)
  4. Add badge to README:

Codecov Configuration

Create .codecov.yml:

Troubleshooting

Common Issues

1. Tests Failing - Missing API Key
Error: ANTHROPIC_API_KEY not set Solution:
2. Kubeconfig Not Working
Error: Unable to connect to cluster Solution:
3. Docker Build Fails
Error: buildx not found Solution: Already handled in workflow with docker/setup-buildx-action@v3
4. CodeQL Initialization Fails
Error: CodeQL not initialized Solution:
  1. Go to Settings → Code security and analysis
  2. Enable CodeQL analysis
  3. Re-run workflow
5. Dependabot PRs Not Auto-Merging
Setup auto-merge:

Debugging Workflows

View Logs
Re-run Failed Jobs
Enable Debug Logging
Add secrets:

Common Issues

1. Workflow Concurrency Issues
Issue: Workflows not canceling as expected Solution:
  1. Check concurrency group configuration
  2. Verify event type (pull_request vs push)
  3. Review workflow run logs for cancellation messages
2. Cache Miss Issues
Issue: Cache not restoring, builds slow Solution:
  1. Verify cache key matches across runs
  2. Check if dependencies changed (invalidates cache)
  3. Review cache size limits (10GB per repo)
3. Artifact Storage Full
Issue: Unable to upload artifacts Solution:
  1. Review artifact retention policies
  2. Clean up old workflow runs: Settings → Actions → General → Artifact retention
  3. Manually delete old artifacts if needed

Workflow Concurrency Controls

All workflows now include concurrency controls to prevent duplicate runs and save CI minutes:

CI/CD Pipeline

  • Cancels duplicate PR builds
  • Allows main/develop builds to complete

Pull Request Checks

  • Uses PR number for better grouping
  • Always cancels previous runs
Benefits:
  • ~30% reduction in CI minutes
  • Faster feedback on latest commits
  • Prevents resource waste

Manual Workflow Triggering

All workflows support manual triggering via workflow_dispatch:
Use cases:
  • Test workflow changes without creating PRs
  • Run security scans on demand
  • Trigger releases manually
  • Debug workflow issues

Build Optimization with Caching

Workflows use GitHub Actions cache to improve performance:

Python Dependencies

Helm Charts

kubectl Binary

Performance Impact:
  • 20-30% faster builds
  • Reduced network usage
  • Better reliability

Artifact Retention Policies

All workflows include retention policies to manage storage costs:

Best Practices

1. Secret Rotation

2. Workflow Optimization

  • Use cache: 'pip' for faster Python setup
  • Use cache-from: type=gha for Docker builds
  • Run independent jobs in parallel
  • Use if conditions to skip unnecessary jobs
  • Leverage concurrency controls to prevent duplicate runs
  • Set appropriate artifact retention policies

3. Security

  • Never log secrets
  • Use secrets.GITHUB_TOKEN instead of PAT when possible
  • Limit secret access with environments
  • Review Dependabot PRs before merging
  • Generate and review SBOM files for releases
  • Run security scans regularly

Additional Resources

Support

For GitHub Actions issues:
  1. Check workflow logs
  2. Review this documentation
  3. Search GitHub Community
  4. Open an issue with ci-cd label

Last Updated: 2025-01-10