cmd-setup-workflows
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/setup-workflows
/setup-workflows
Agent skill wrapper for the Claude command .
/setup-workflowsWhen the original command text references , , or named arguments, map them from the user's current request.
{{INPUT}}$1Claude命令的Agent技能封装。
/setup-workflows当原始命令文本引用、或命名参数时,从用户当前请求中映射这些参数。
{{INPUT}}$1Command Instructions
命令说明
Task
任务
Create or update GitHub Actions workflows in .
.github/workflows/在目录下创建或更新GitHub Actions工作流。
.github/workflows/Detection Phase
检测阶段
First, detect the project ecosystem by inspecting the repo root:
- Language & package manager: Check for ,
mix.exs,package.json,Cargo.toml,go.mod,pubspec.yaml,pyproject.toml,Makefile, etc.flake.nix - Project type: Determine if this is a library/package or an application — this affects whether publishes to a registry.
release.yml - Existing workflows: Read any existing to preserve custom jobs or secrets already configured.
.github/workflows/*.yml - Test framework: Detect test runner from config (ExUnit, Jest/Vitest, cargo test, go test, flutter_test, pytest, etc.)
- Build tool: Detect build commands (mix compile, npm run build, cargo build, go build, flutter build, etc.)
- Linter/formatter: Detect available checks (mix format --check-formatted, mix credo, eslint, clippy, go vet, dart analyze, ruff, etc.)
首先,通过检查仓库根目录来检测项目生态系统:
- 语言与包管理器:检查是否存在、
mix.exs、package.json、Cargo.toml、go.mod、pubspec.yaml、pyproject.toml、Makefile等文件。flake.nix - 项目类型:确定这是一个库/包还是应用程序——这会影响是否向注册表发布内容。
release.yml - 现有工作流:读取所有已存在的文件,以保留已配置的自定义任务或密钥。
.github/workflows/*.yml - 测试框架:从配置中检测测试运行器(ExUnit、Jest/Vitest、cargo test、go test、flutter_test、pytest等)。
- 构建工具:检测构建命令(mix compile、npm run build、cargo build、go build、flutter build等)。
- 代码检查器/格式化工具:检测可用的检查项(mix format --check-formatted、mix credo、eslint、clippy、go vet、dart analyze、ruff等)。
Workflow Definitions
工作流定义
Generate only the workflows that apply. Use the detected ecosystem to fill in concrete commands — never use placeholder commands.
仅生成适用的工作流。使用检测到的生态系统填充具体命令——切勿使用占位符命令。
1. ci.yml
— Static checks & build
ci.yml1. ci.yml
—— 静态检查与构建
ci.yml- Trigger: to any branch,
pushto any branchpull_request - Jobs: format check, lint, build (compile/typecheck) — can be parallel jobs or sequential steps, whichever fits the ecosystem
- No tests in this workflow
- Cache: dependencies (hex/deps, node_modules, target/, pkg cache, pub cache, etc.)
- 触发条件:推送至任意分支、针对任意分支的拉取请求
- 任务:格式检查、代码检查、构建(编译/类型检查)——可采用并行任务或顺序步骤,以适配生态系统为准
- 此工作流不包含测试
- 缓存:依赖项(hex/deps、node_modules、target/、pkg缓存、pub缓存等)
2. test.yml
— Unit tests
test.yml2. test.yml
—— 单元测试
test.yml- Trigger: to
pushonly,maintargetingpull_requestmain - Jobs: run unit test suite
- Services: if tests need a database (Postgres, Redis, etc.), add service containers detected from config (e.g. ,
config/test.exs,docker-compose.yml).env.test - Cache: dependencies
- 触发条件:仅推送至分支、针对
main分支的拉取请求main - 任务:运行单元测试套件
- 服务:如果测试需要数据库(Postgres、Redis等),从配置中添加服务容器(例如、
config/test.exs、docker-compose.yml).env.test - 缓存:依赖项
3. release.yml
— Manual release
release.yml3. release.yml
—— 手动发布
release.yml- Trigger: with inputs:
workflow_dispatch- (string, required, description: "Release version (e.g. 1.2.3)")
version - (string, required, default: "main", description: "Git ref to release from")
git_ref
- Steps in order:
- Checkout at
git_ref - Setup language toolchain
- Update version in the canonical version file (,
mix.exs,package.json,Cargo.toml,pubspec.yaml, etc.) to the inputpyproject.tomlversion - Build the package/artifact
- If library/package: publish to registry (hex.pm, npm, crates.io, pub.dev, pypi, etc.) — use appropriate secrets (,
HEX_API_KEY,NPM_TOKEN,CARGO_REGISTRY_TOKEN,PUB_CREDENTIALS, etc.)PYPI_TOKEN - If application: skip publish, but upload build artifacts
- Commit the version bump:
git commit -am "chore(release): v${version}" - Create git tag:
v${version} - Push commit and tag
- Create GitHub Release via or
gh release create— include release notes (auto-generate from commits since last tag), upload build artifactssoftprops/action-gh-release
- Checkout at
- Permissions:
contents: write
- 触发条件:带输入参数的:
workflow_dispatch- (字符串,必填,描述:"发布版本(例如1.2.3)")
version - (字符串,必填,默认值:"main",描述:"用于发布的Git引用")
git_ref
- 步骤顺序:
- 基于检出代码
git_ref - 设置语言工具链
- 将规范版本文件(、
mix.exs、package.json、Cargo.toml、pubspec.yaml等)中的版本更新为输入的pyproject.tomlversion - 构建包/制品
- 如果是库/包:发布至注册表(hex.pm、npm、crates.io、pub.dev、pypi等)——使用相应的密钥(、
HEX_API_KEY、NPM_TOKEN、CARGO_REGISTRY_TOKEN、PUB_CREDENTIALS等)PYPI_TOKEN - 如果是应用程序:跳过发布,但上传构建制品
- 提交版本更新:
git commit -am "chore(release): v${version}" - 创建Git标签:
v${version} - 推送提交和标签
- 通过或
gh release create创建GitHub Release——包含发布说明(从上次标签以来的提交自动生成),并上传构建制品softprops/action-gh-release
- 基于
- 权限:
contents: write
4. e2e.yml
— End-to-end tests (only if $ARGUMENTS
contains "e2e")
e2e.yml$ARGUMENTS4. e2e.yml
—— 端到端测试(仅当$ARGUMENTS
包含"e2e"时生成)
e2e.yml$ARGUMENTS- Trigger: with input:
workflow_dispatch- (string, required, description: "Release version to test")
version
- Steps:
- Fetch the release artifacts from GitHub Releases for the given version
- Setup test environment (install deps, start services)
- Run e2e test suite
- Only generate this file when the user explicitly passes "e2e" as argument
- 触发条件:带输入参数的:
workflow_dispatch- (字符串,必填,描述:"要测试的发布版本")
version
- 步骤:
- 从GitHub Releases获取指定版本的发布制品
- 设置测试环境(安装依赖、启动服务)
- 运行端到端测试套件
- 仅当用户明确传入"e2e"作为参数时才生成此文件
Output Rules
输出规则
- Use the latest stable action versions (e.g. ,
actions/checkout@v4,actions/setup-node@v4)erlef/setup-beam@v1 - Set explicitly on each workflow — principle of least privilege
permissions - Every workflow must set to cancel redundant runs:
concurrencyyamlconcurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - Use in matrix strategies if applicable
fail-fast: false - Prefer pinned action versions over
@latest - Name each workflow clearly with a field
name: - If existing workflow files are found, update them in place preserving any custom secrets, env vars, or extra jobs the user added — do not blindly overwrite
- 使用最新稳定版本的Action(例如、
actions/checkout@v4、actions/setup-node@v4)erlef/setup-beam@v1 - 在每个工作流中显式设置——遵循最小权限原则
permissions - 每个工作流必须设置以取消冗余运行:
concurrencyyamlconcurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - 如果适用,在矩阵策略中使用
fail-fast: false - 优先使用固定版本的Action而非
@latest - 为每个工作流设置清晰的字段
name: - 如果发现现有工作流文件,就地更新,保留用户添加的任何自定义密钥、环境变量或额外任务——切勿盲目覆盖
Commit
提交
After writing all workflow files, create a single commit:
ci(github): update github actions workflowsDo NOT push. Report what was created/updated.
编写完所有工作流文件后,创建一个单独的提交:
ci(github): update github actions workflows请勿推送。报告已创建/更新的内容。