laolaoshiren/github-actions-gen
分析真实项目并生成或修订安全、可验证的 GitHub Actions workflow;当用户要求创建 CI、测试矩阵、构建、Release、部署、缓存、Secrets、OIDC、PR 自动化或排查 workflow 配置时使用
npx skills add https://github.com/laolaoshiren/claude-code-skills-zh --skill github-actions-gen
pull_request_target 执行 PR 代码。@main、@master、@latest 或可移动的 @vN tag。permissions 和 timeout-minutes;不依赖仓库默认权限。package.json、.nvmrc、pyproject.toml、go.mod、Cargo.toml、Dockerfile 与 .github/workflows/。pull_request:按不可信代码处理,使用只读 Token,不提供 Secrets,不在高权限自托管 Runner 上执行 fork 代码。pull_request_target:仅处理标签、评论等可信基准分支逻辑;绝不 checkout PR head、运行 PR 脚本或安装 PR 依赖。push / tag / workflow_dispatch:仍需限制分支、输入、Environment 和权限;写操作放入独立 job。${{ github.event.* }} 等不可信表达式直接插进 run:。通过 env: 传值,并在脚本中按数据处理。优先拆分职责:
ci.yml:lint、test、build;pull_request 与受控 push 触发,只读权限。release.yml:仅在用户明确要求时生成;使用受保护 tag 或手动触发。deploy.yml:仅在部署目标明确时生成;使用 GitHub Environment、并发控制和最小 OIDC / Secrets 权限。为耗时 job 设置取消策略和超时。矩阵只覆盖项目真正支持的版本;缓存 key 必须包含 lockfile,不能缓存凭据和构建秘密。
uses: owner/action@<40位SHA> # vX.Y.Z 格式。版本注释用于阅读,SHA 才是执行边界。actions/checkout 默认设置 persist-credentials: false。只有后续步骤确实要执行经过授权的 Git 写入时才保留凭据,并限制 job 权限。下面示例假设项目已有 .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 和命令。
contents: write、packages: write 或 id-token: write。workflow_dispatch 输入设置类型、选项和默认值;在执行前再次校验目标环境与版本。actionlint;若工具不可用,明确说明未完成该门禁,不要声称语法通过。${{ }}、shell、路径、矩阵和 needs 引用。uses:,确认第三方 Action 都是完整 SHA;检查 checkout 的 persist-credentials。.env 或无关配置。用中文说明:
除非用户明确要求,不额外创建 README-CICD.md 等辅助文档。
persist-credentials: falsepull_request_target 不执行不可信 PR 内容actionlint 与项目命令验证已完成或如实记录缺口Take laolaoshiren/github-actions-gen from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.