Spartan-ai-toolkit ci-cd-patterns
CI/CD pipeline patterns for GitHub Actions, PR automation, and deployment workflows. Use when setting up CI, fixing broken pipelines, automating PR checks, or configuring deployment.
install
source · Clone the upstream repo
git clone https://github.com/c0x12c/ai-toolkit
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/c0x12c/ai-toolkit "$T" && mkdir -p ~/.claude/skills && cp -r "$T/toolkit/skills/ci-cd-patterns" ~/.claude/skills/spartan-stratos-spartan-ai-toolkit-ci-cd-patterns && rm -rf "$T"
manifest:
toolkit/skills/ci-cd-patterns/SKILL.mdsource content
CI/CD Patterns
Patterns for GitHub Actions, PR automation, and deployment workflows.
When to Use
- Setting up or fixing GitHub Actions workflows
- Automating PR checks (lint, test, build)
- Configuring deployment pipelines
- Monitoring PR status and retrying flaky CI
- Setting up multi-environment deployment (dev, staging, prod)
GitHub Actions --- Common Patterns
Basic CI Workflow
name: CI on: push: branches: [main, develop] pull_request: branches: [main, develop] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run tests run: ./gradlew test
PR Check Workflow
name: PR Check on: pull_request jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: ./gradlew ktlintCheck test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: ./gradlew test build: runs-on: ubuntu-latest needs: [lint, test] steps: - uses: actions/checkout@v4 - run: ./gradlew build
PR Babysitting Pattern
Monitor a PR through CI, handle common failures:
- Check CI status ---
gh pr checks <number> - Identify failure type --- flaky test, lint error, build failure
- Fix and push --- for lint/build errors, fix locally and push
- Retry flaky tests --- re-run the workflow:
gh run rerun <run-id> --failed - Resolve merge conflicts --- rebase onto target branch
- Enable auto-merge ---
gh pr merge <number> --auto --squash
See
for ready-to-use GitHub Actions YAML templates.workflows.md
Deployment Checklist
Before deploying:
- All CI checks pass
- No merge conflicts
- Database migrations reviewed (if any)
- Environment variables set in target environment
- Rollback plan identified
Gotchas
- Caching saves minutes per run. Always cache dependencies (
oractions/cache
with cache). A cold Gradle build takes 3-5 minutes, cached takes 30 seconds.actions/setup-java
creates sequential dependencies. Without it, all jobs run in parallel. Useneeds:
to make build wait for checks.needs: [lint, test]- Secret names are case-sensitive.
andsecrets.DB_PASSWORD
are different. Match the exact name from Settings > Secrets.secrets.db_password - Don't use
--- useactions/checkout@v3
. v3 uses Node 16 which is deprecated. v4 uses Node 20.v4 - Flaky tests need investigation, not just retry. If you re-run a workflow more than twice for the same test, fix the test. Common causes: race conditions, time-dependent assertions, shared test state.
- Force-pushing during CI review resets the check suite. Wait for CI to finish before force-pushing, or you'll waste runner minutes.
Rules
- Every PR must pass CI before merge
- Don't skip CI checks (
) unless it's docs-only[skip ci] - Keep workflows under 10 minutes total
- Use matrix builds for multi-version testing
- Store secrets in GitHub Secrets, never in code