agentleFS
KubementatKubementat/ai_agent_skills/skills/github-actions-cicd/SKILL.md

github-actions-cicd

Skill2 starsChanged 8 months agoMITView on GitHub

Expert implementation and optimization of GitHub Actions CI/CD pipelines. Use when designing workflows, debugging pipeline failures, optimizing build times, or implementing best practices for continuous integration and deployment.

  • Reads credentials
  • Installs packages

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Best Practice: Use paths to filter irrelevant changes:

    line 71
  2. Distinctive:

    Use matrices to test across multiple configurations:

    line 105
  3. Very specific:

    Use hashFiles() for cache invalidation on lockfile changes

    line 150
  4. Very specific:

    Use actionlint for syntax validation:

    line 240
  5. Distinctive:

    Path filtering: Only run workflows on relevant file changes

    line 255
  6. Distinctive:

    Self-hosted runners: Use faster hardware for heavy workloads

    line 257
  7. Distinctive:

    Avoid redundant steps: Don't checkout or install if not needed

    line 258
  8. Distinctive:

    Explicit waits: instead of arbitrary sleep times

    line 301
  9. Distinctive:

    Test data isolation: Create/cleanup unique data per run

    line 312
  10. Distinctive:

    Ensure required fields present

    line 357

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GitHub Actions CI/CD Specialist

Expert guidance on implementing, debugging, and optimizing GitHub Actions workflows for CI/CD pipelines.

When to Use This Skill

Activate this skill when the user:

  • Wants to create or modify a .github/workflows/*.yml file
  • Experiences workflow failures and needs troubleshooting help
  • Asks about matrix builds, caching strategies, or secrets management
  • Needs guidance on CI/CD best practices
  • Wants to optimize pipeline performance

Core Workflow Structure

Basic Template

name: CI Pipeline
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read

env:
  NODE_ENV: production

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      
      - run: npm ci
      - run: npm test

Key Implementation Guidelines

1. Workflow Triggers (on)

Choose appropriate triggers to balance responsiveness and cost:

Trigger TypeUse CaseExample
pushMain branch deploymentsbranches: [main, develop]
pull_requestPR validationbranches: [main]
workflow_dispatchManual triggeringFor ad-hoc runs
schedulePeriodic jobscron: '0 0 * * *'

Best Practice: Use paths to filter irrelevant changes:

on:
  push:
    branches: [main]
    paths:
      - 'src/**'
      - '.github/workflows/*.yml'

2. Job Configuration

Each job should have:

  • runs-on: Specify runner (ubuntu-latest, windows-latest, self-hosted)
  • timeout-minutes: Prevent hung jobs (recommended: 15-30 min for CI)
  • env: Job-level environment variables
  • needs: Dependencies on other jobs

Example:

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    env:
      CI: true
    strategy:
      matrix:
        node-version: [18, 20, 22]
    steps:

3. Matrix Strategy for Parallel Testing

Use matrices to test across multiple configurations:

strategy:
  fail-fast: false  # Continue all jobs even if one fails
  matrix:
    node-version: [18, 20, 22]
    os: [ubuntu-latest, windows-latest]

Advanced Matrix Patterns:

  • Include specific combinations:
strategy:
  matrix:
    include:
      - node: 20
        experimental: false
      - node: 21
        experimental: true
  • Dynamic matrices based on code changes:
# Use outputs from previous jobs to adjust matrix
if: ${{ matrix.unit-test-this-shard == 'true' }}

4. Caching Dependencies

Optimize build times with intelligent caching:

- name: Cache node modules
  uses: actions/cache@v4
  with:
    path: ~/.npm
    key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      ${{ runner.os }}-node-${{ matrix.node-version }}-

Caching Best Practices:

  • Cache at the job level, before dependency installation
  • Use hashFiles() for cache invalidation on lockfile changes
  • Include OS and runtime version in cache key to prevent conflicts
  • Provide restore-keys for partial matches

5. Secrets Management

Proper secrets usage patterns:

Standard approach:

steps:
  - name: Deploy with API key
    env:
      API_KEY: ${{ secrets.API_KEY }}
    run: ./deploy.sh

In matrix strategy:

strategy:
  matrix:
    include:
      - org: apples
        secret_name: APPLES_API_KEY
      - org: bananas  
        secret_name: BANANAS_API_KEY
steps:
  - env:
      API_KEY: ${{ secrets[matrix.secret_name] }}

Environment-level secrets: For deployment workflows, use GitHub Environments with protected secrets.

6. Permissions Configuration

Explicit permissions improve security:

permissions:
  contents: read       # For checkout
  packages: write      # For pushing container images
  id-token: write      # For OIDC authentication

Common permission combinations:

  • Read-only CI: contents: read
  • PR with comments: contents: read, pull-requests: write
  • Package publishing: contents: write, packages: write

Debugging Workflow Failures

Common Issues & Solutions

ProblemDiagnosisSolution
Job hangs/timeoutCheck timeout-minutes, add debug loggingIncrease timeout or investigate infinite loops
Cache missesInspect cache key patternVerify hashFiles path and key structure
Secret not availableCheck scope (repo vs env)Use correct secrets context or environment
Matrix job failuresReview fail-fast settingSet fail-fast: false for complete results
Permission deniedAudit permissions blockAdd specific permission grants

Debugging Techniques

1. Enable step-level debugging:

env:
  ACTIONS_RUNNER_DEBUG: true
  ACTIONS_STEP_DEBUG: true

2. Add diagnostic steps:

- name: Debug environment
  run: |
    echo "GITHUB_REF: ${{ github.ref }}"
    echo "Matrix value: ${{ matrix.os }}"
    env | sort

3. Use structured logging:

# In shell scripts
echo "::group::Setup Phase
# ... commands ...
echo ::endgroup::

Workflow Validation

Use actionlint for syntax validation:

actionlint .github/workflows/*.yml

Common linting issues:

  • Missing quotes around expressions with special characters
  • Incorrect action versions (use @v4 not @main)
  • Permission scope mismatches

Performance Optimization

Strategies to Reduce CI Time

  1. Parallel jobs: Split independent test suites into parallel jobs
  2. Path filtering: Only run workflows on relevant file changes
  3. Caching: Cache dependencies, build outputs, and generated assets
  4. Self-hosted runners: Use faster hardware for heavy workloads
  5. Avoid redundant steps: Don't checkout or install if not needed

Example: Optimized Multi-Stage Pipeline

jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
      artifact-path: ${{ steps.build.outputs.path }}
    steps:
      - uses: actions/checkout@v4
      
      - name: Cache deps
        uses: actions/cache@v4
        with:
          path: node_modules
          key: deps-${{ hashFiles('**/package-lock.json') }}
      
      - id: build
        run: |
          npm ci
          npm run build
          echo "path=dist/" >> $GITHUB_OUTPUT

  test:
    runs-on: ubuntu-latest  
    needs: build
    steps:
      - uses: actions/checkout@v4
      
      - name: Download artifact
        uses: actions/download-artifact@v4
        with:
          name: build-output
          
      - run: npm test

Flakiness Mitigation

For reliable CI/CD:

  1. Explicit waits instead of arbitrary sleep times
  2. Retry logic for transient failures:
- uses: nick-fields/retry@v3
  with:
    timeout_minutes: 5
    max_attempts: 3
    command: npm test
  1. Robust selectors in E2E tests (data-testid attributes)
  2. Test data isolation: Create/cleanup unique data per run
  3. Avoid shared state: Each job should be idempotent

Workflow Templates

Standard CI Pipeline

See assets/templates/ci-pipeline.yml for a production-ready template covering:

  • Code checkout with sparse checkout option
  • Dependency caching with lockfile hashing
  • Matrix testing across versions
  • Artifact collection and upload
  • Coverage reporting integration

Multi-Environment Deployment

See assets/templates/deploy-multi-env.yml for:

  • Environment-based secrets management
  • Approval gates between stages
  • Rollback strategies
  • Health check validation

Reference Files

FilePurposeWhen to Load
SYNTAX_REFERENCE.mdComplete YAML schema referenceBuilding new workflows
BEST_PRACTICES.mdIndustry best practicesOptimizing existing pipelines
TROUBLESHOOTING.mdDebug common failure modesDiagnosing failed runs

Scripts

Analyze Workflow Performance

Run scripts/analyze_workflow.py to:

  • Identify bottlenecks in execution time
  • Suggest caching opportunities
  • Flag permission issues
  • Detect anti-patterns

Validate Syntax

Use scripts/validate_syntax.sh to:

  • Check YAML validity
  • Verify action versions
  • Ensure required fields present

Examples

Simple CI Pipeline

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - run: npm test

Matrix Build Example

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python: ['3.9', '3.10', '3.11']
    steps:
      - uses: actions/checkout@v4
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
      - run: pip install -r requirements.txt
      - run: pytest tests/

Activation Keywords

This skill activates when user mentions:

  • "GitHub Actions workflow" or ".github/workflows"
  • "CI/CD pipeline"
  • "workflow file" or "action yml"
  • "matrix build" or "parallel testing"
  • "debug GitHub Actions" or "pipeline failed"
  • "optimize CI time" or "cache dependencies"

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.