Github actions gen

From laolaoshiren/claude-code-skills-zh · View interactive version

Github actions gen is an AI agent skill from the GitHub repository laolaoshiren/claude-code-skills-zh. 分析真实项目并生成或修订安全、可验证的 GitHub Actions workflow;当用户要求创建 CI、测试矩阵、构建、Release、部署、缓存、Secrets、OIDC、PR 自动化或排查 workflow 配置时使用

How to use this skill

Skill file

GitHub Actions CI/CD 生成器

核心原则

工作流程

1. 盘点项目证据

2. 建立威胁模型

3. 设计最小流水线

优先拆分职责:

为耗时 job 设置取消策略和超时。矩阵只覆盖项目真正支持的版本;缓存 key 必须包含 lockfile,不能缓存凭据和构建秘密。

4. 核验并固定 Action

5. 生成 workflow

下面示例假设项目已有 .nvmrc、package-lock.json、lint、test 和 build 脚本:

name: CI

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

permissions:
  contents: read

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: 配置 Node.js
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
        with:
          node-version-file: .nvmrc
          cache: npm
          cache-dependency-path: package-lock.json

      - name: 安装依赖
        run: npm ci

      - name: 代码检查
        run: npm run lint

      - name: 运行测试
        run: npm test

      - name: 构建
        run: npm run build

不要机械复制示例。若项目使用 pnpm、Yarn、uv、Poetry、Gradle、Go 或 Rust,应使用其真实锁文件、wrapper 和命令。

6. 单独保护发布与部署

7. 验证

交付格式

用中文说明:

  1. 新增或修改的 workflow 及触发条件;
  2. 每个 job 的权限、Secrets / OIDC 和 Environment 边界;
  3. Action SHA 的版本来源与核验时间;
  4. 已运行的验证、结果和未覆盖项;
  5. 发布 / 部署的人工确认点与回滚方式。

除非用户明确要求,不额外创建 README-CICD.md 等辅助文档。

质量检查清单

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.