agentleFS
28672032962867203296/hermes-agent/skills/devops/cicd-pipeline-templates/SKILL.md

cicd-pipeline-templates

Skill0 starsChanged 3 months agoMITView on GitHub

CI/CD 模板:GitHub Actions Python、测试、lint、构建发布.

  • Installs packages

The file

Files
SKILL.md

CI/CD 流水线模板

借鉴 actions/starter-workflows (12k⭐) + sdras/awesome-actions (28k⭐)。

GitHub Actions 标准模板

Python 项目(最常用)

# .github/workflows/ci.yml
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11", "3.12"]

    steps:
    - uses: actions/checkout@v4

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}
        cache: 'pip'

    - name: Install dependencies
      run: |
        pip install --upgrade pip
        pip install ruff pytest pytest-cov
        pip install -r requirements.txt

    - name: Lint with ruff
      run: ruff check .

    - name: Test with pytest
      run: pytest --cov=src --cov-report=xml

    - name: Upload coverage
      uses: codecov/codecov-action@v4
      with:
        file: ./coverage.xml

构建产物 + 发布

# .github/workflows/release.yml
name: Release

on:
  push:
    tags: ['v*']

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: '3.11'

    - name: Build package
      run: |
        pip install build
        python -m build

    - name: Upload to GitHub Release
      uses: softprops/action-gh-release@v2
      with:
        files: dist/*

关键 Actions 速查

Action用途
actions/checkout@v4检出代码
actions/setup-python@v5设置 Python
actions/cache@v4缓存依赖
actions/upload-artifact@v4上传构建产物
softprops/action-gh-release@v2发布 GitHub Release
peaceiris/actions-gh-pages@v3部署 GitHub Pages

Secrets 管理

永远不在 workflow 里写密钥!用 GitHub Secrets:

  • Settings → Secrets and variables → Actions
  • 引用:${{ secrets.MY_SECRET }}

触发策略

on:
  push:
    branches: [main]           # main 分支 push 时触发
    paths:
      - 'src/**'                # 只关注 src 变更
  pull_request:
    branches: [main]
  schedule:
    - cron: '0 8 * * 1'        # 每周一早8点
  workflow_dispatch:            # 手动触发

环境部署

deploy:
  needs: test
  runs-on: ubuntu-latest
  environment: production       # 需要审批才能执行
  steps:
    - run: ./deploy.sh

本地测试

在提交前可以用 act 在本地跑 workflow:

# 安装 act
choco install act-cli  # Windows
brew install act        # Mac

# 本地运行
act push
act -j test            # 只跑 test job

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.