# GitHub CI/CD Patterns for AI-Driven Development

## META
- created: 2026-02-14
- type: knowledge base
- references: github-strategy.md, test-strategy.md, get-er-done-methodology.md

## OVERVIEW
Patterns for using GitHub as the single source of truth for AI agent-built software. Covers Actions, issue-driven development, Copilot integration, and sync protocols.

## GITHUB ACTIONS PIPELINE ARCHITECTURE

### Trigger Strategy
- push to main: full CI (lint + unit + integration + contract + security + build)
- pull_request: same as push, plus spec tests and E2E
- workflow_dispatch: manual trigger for performance tests
- schedule: nightly full suite including performance
- release (tag v*): full CI + build artifacts + publish + deploy

### Job Dependencies (DAG)
```
lint -> test-unit (parallel: py3.11, py3.12) -> test-integration -> test-contract
                                              -> test-spec
                                              -> security
                                              -> build -> test-e2e -> publish (release only)
```

### Concurrency Control
- Cancel superseded runs on same branch
- Matrix strategy for Python versions
- Reusable workflows for common patterns

### Caching
- pip cache: actions/cache with requirements hash
- Docker layer cache: docker/build-push-action with cache-from/cache-to
- Test fixtures: cached between runs when deterministic

## COPILOT CODING AGENT INTEGRATION

### AGENTS.md (repo root)
Instructs all AI agents (Copilot, Claude, Cursor) on:
- Coding standards (formatter, linter, type checker)
- Test requirements (TDD, coverage thresholds)
- Architecture constraints (which patterns to use/avoid)
- File organization (where new code goes)
- Build commands (how to test, lint, build)

### copilot-setup-steps.yml
Pre-configures Copilot's ephemeral dev environment:
- Python version + dev dependencies
- Docker + test containers
- Environment variables
- Pre-downloaded test fixtures

### Issue-to-PR Workflow
1. Issue created with agent-ready label
2. Copilot assigned (or self-assigns via agentic workflow)
3. Copilot reads issue + AGENTS.md + relevant code
4. Copilot creates branch, writes code + tests
5. Copilot opens PR referencing issue
6. CI runs automatically
7. Human reviews + approves
8. Auto-merge if all checks pass

## GITHUB AGENTIC WORKFLOWS (Feb 2026)

### What They Are
Markdown-defined automation that uses AI agents within GitHub Actions. Define intent in plain English, agent executes with guardrails.

### Patterns
- Auto-triage: New issues auto-labeled and routed to correct project board
- Auto-review: AI code review suggestions on PRs
- Auto-docs: Documentation updated when code changes
- CI failure investigation: Agent reads failure logs, suggests fixes
- Dependency updates: Agent evaluates and applies dependency updates

### Security Model
- Read-only by default
- Write operations limited to pre-approved outputs (PRs, comments, labels)
- Sandboxed execution in Actions runners
- Team-visible logs for all agent actions

## SYNC PROTOCOL
1. Code: GitHub repo (main branch = truth)
2. Docs: docs/ directory in repo (not external wiki)
3. Tasks: GitHub Issues + Projects (not external Jira)
4. Decisions: ADRs in docs/architecture/ or issue comments
5. CI/CD: GitHub Actions (not external Jenkins)
6. Artifacts: GitHub Releases + ghcr.io (Docker images)
7. Discussion: GitHub Discussions (not external Slack for decisions)
8. Config: .github/ directory defines all automation

## BRANCH PROTECTION
- main: require PR + CI pass + 1 approval + no force push
- Feature branches: short-lived (<1 week), named feature/issue-N-desc
- Trunk-based development recommended for AI agent workflows
- Dependabot + CodeQL enabled

## METRICS (DORA-aligned)
- Deployment frequency: target weekly
- Lead time for changes: target <1 day
- Change failure rate: target <5%
- Mean time to recovery: target <1 hour
- Additional: test coverage trend, PR merge time, sprint velocity
