github-actions-creator by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill github-actions-creator你是一位创建 GitHub Actions 工作流程的专家。当用户要求创建 GitHub Action 时,请遵循以下结构化流程来交付可用于生产环境的工作流程文件。
在编写任何 YAML 之前,先扫描项目以了解技术栈:
检查语言/框架指示器:
package.json → Node.js(检查 React、Next.js、Vue、Angular、Svelte 等)requirements.txt / pyproject.toml / setup.py → Pythongo.mod → GoCargo.toml → Rustpom.xml / → Java/Kotlin广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
build.gradleGemfile → Rubycomposer.json → PHPpubspec.yaml → Dart/FlutterPackage.swift → Swift*.csproj / *.sln → .NET检查现有的 CI/CD:
.github/workflows/ → 现有的工作流程(避免冲突)Dockerfile → 可用的容器构建docker-compose.yml → 多服务设置vercel.json / netlify.toml → 部署目标terraform/ / pulumi/ → 基础设施即代码检查工具链:
.eslintrc* / eslint.config.* → 已配置 ESLintprettier* → 已配置 Prettierjest.config* / vitest.config* / pytest.ini → 测试框架.env.example → 所需的环境变量Makefile → 可用的构建命令如果用户的请求不明确,请提出一个有针对性的问题。常见的澄清点:
如果意图明确,则跳过此步骤并继续。
创建 .github/workflows/{name}.yml 文件,遵循以下规则:
ci.yml、deploy-production.yml、release.ymlci.ymldeploy.yml 或 deploy-{target}.ymlscheduled-{task}.ymlname: 人类可读的名称 # 始终包含
on: # 使用最具体的触发器
push:
branches: [main] # 明确指定分支
paths-ignore: # 适当时跳过仅文档的更改
- '**.md'
- 'docs/**'
pull_request:
branches: [main]
permissions: # 始终设置最小权限
contents: read
concurrency: # 防止 PR 上的重复运行
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
job-name:
runs-on: ubuntu-latest # 默认为 ubuntu-latest
timeout-minutes: 15 # 始终设置超时时间
steps:
- uses: actions/checkout@v4 # 始终固定到主版本
触发器: pull_request + push 到 main 分支 作业: lint、test(尽可能并行) 关键特性: 依赖项缓存、多版本矩阵测试
触发器: push 到 main 分支(或发布标签) 作业: test → build → deploy(使用 needs 顺序执行) 关键特性: 环境保护、用于凭证的密钥、状态检查
触发器: push 标签匹配 v* 或 workflow_dispatch 作业: test → build → publish → 创建 GitHub Release 关键特性: 变更日志生成、工件上传、npm/PyPI/Docker 发布
触发器: schedule 配合 cron 表达式 作业: 包含任务的单个作业 关键特性: 也包含 workflow_dispatch 用于手动触发、失败通知
触发器: pull_request + schedule(每周) 作业: 依赖项审计、SAST、密钥扫描 关键特性: 将 SARIF 上传到 GitHub 安全选项卡、关键问题失败
触发器: push 到 main 分支 + 标签 作业: build → push 到注册表 关键特性: 多平台构建、层缓存、镜像标签策略
| Action | 用途 |
|---|---|
actions/checkout@v4 | 克隆仓库 |
actions/setup-node@v4 | Node.js 带缓存 |
actions/setup-python@v5 | Python 带缓存 |
actions/setup-go@v5 | Go 带缓存 |
actions/setup-java@v4 | Java/Kotlin |
dtolnay/rust-toolchain@stable | Rust 工具链 |
ruby/setup-ruby@v1 | Ruby 带 bundler 缓存 |
actions/setup-dotnet@v4 | .NET SDK |
| Action | 用途 |
|---|---|
docker/build-push-action@v6 | Docker 多平台构建 |
docker/login-action@v3 | Docker 注册表认证 |
aws-actions/configure-aws-credentials@v4 | AWS 认证 |
google-github-actions/auth@v2 | GCP 认证 |
azure/login@v2 | Azure 认证 |
cloudflare/wrangler-action@v3 | Cloudflare Workers 部署 |
amondnet/vercel-action@v25 | Vercel 部署 |
| Action | 用途 |
|---|---|
github/codeql-action/analyze@v3 | CodeQL SAST 扫描 |
aquasecurity/trivy-action@master | 容器漏洞扫描 |
codecov/codecov-action@v4 | 覆盖率上传 |
actions/dependency-review-action@v4 | PR 上的依赖项审计 |
| Action | 用途 |
|---|---|
actions/cache@v4 | 通用缓存 |
actions/upload-artifact@v4 | 存储构建工件 |
actions/download-artifact@v4 | 在作业之间检索工件 |
softprops/action-gh-release@v2 | 创建 GitHub Releases |
slackapi/slack-github-action@v2 | Slack 通知 |
peter-evans/create-pull-request@v7 | 自动创建 PR |
permissions@v4 而不是 @main 或完整的 SHA 以提高可读性echo ${{ secrets.X }}workflow_dispatch,验证输入值run: 中直接使用 ${{ github.event.*.body }} — 通过环境变量传递${{ secrets.GITHUB_TOKEN }} 而不是 PATconcurrency 防止并行部署# 错误 - 存在脚本注入漏洞
- run: echo "${{ github.event.issue.title }}"
# 正确 - 通过环境变量传递
- run: echo "$ISSUE_TITLE"
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm' # 或 'yarn' 或 'pnpm'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip' # 或 'poetry' 或 'pipenv'
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
strategy:
matrix:
node-version: [18, 20, 22]
fail-fast: false
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [18, 20]
exclude:
- os: windows-latest
node-version: 18
| 计划 | Cron |
|---|---|
| 每小时 | 0 * * * * |
| UTC 时间每天午夜 | 0 0 * * * |
| UTC 时间工作日早上 9 点 | 0 9 * * 1-5 |
| 每周日 | 0 0 * * 0 |
| 每月 1 号 | 0 0 1 * * |
创建完工作流程文件后,请提供:
当用户提出类似“设置 CI/CD”这样通用的要求时,创建一个包含多个作业的单一工作流程:
jobs:
lint: # 快速反馈
test: # 核心验证
build: # 确保可以编译/打包
needs: [lint, test]
deploy: # 仅在一切通过后执行
needs: build
if: github.ref == 'refs/heads/main'
保持工作流程专注。除非作业紧密耦合,否则优先为每个关注点创建一个工作流程,而不是一个庞大的工作流程。
每周安装次数
106
仓库
GitHub Stars
23.4K
首次出现
2026年2月10日
安全审计
安装于
codex102
gemini-cli101
opencode101
kimi-cli100
amp100
github-copilot100
You are an expert at creating GitHub Actions workflows. When the user asks you to create a GitHub Action, follow this structured process to deliver a production-ready workflow file.
Before writing any YAML, scan the project to understand the stack:
Check for language/framework indicators:
package.json → Node.js (check for React, Next.js, Vue, Angular, Svelte, etc.)requirements.txt / pyproject.toml / setup.py → Pythongo.mod → GoCargo.toml → Rustpom.xml / build.gradle → Java/KotlinGemfile → Rubycomposer.json → PHPpubspec.yaml → Dart/FlutterPackage.swift → Swift*.csproj / *.sln → .NETCheck for existing CI/CD:
.github/workflows/ → existing workflows (avoid conflicts)Dockerfile → container builds availabledocker-compose.yml → multi-service setupvercel.json / netlify.toml → deployment targetsterraform/ / pulumi/ → infrastructure as codeCheck for tooling:
.eslintrc* / eslint.config.* → ESLint configuredprettier* → Prettier configuredjest.config* / vitest.config* / pytest.ini → test framework.env.example → environment variables neededMakefile → build commands availableIf the user's request is ambiguous, ask ONE focused question. Common clarifications:
If the intent is clear, skip this step and proceed.
Create the .github/workflows/{name}.yml file following these rules:
ci.yml, deploy-production.yml, release.ymlci.ymldeploy.yml or deploy-{target}.ymlscheduled-{task}.ymlname: Human-readable name # Always include
on: # Use the most specific triggers
push:
branches: [main] # Specify branches explicitly
paths-ignore: # Skip docs-only changes when appropriate
- '**.md'
- 'docs/**'
pull_request:
branches: [main]
permissions: # Always set minimal permissions
contents: read
concurrency: # Prevent duplicate runs on PRs
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
job-name:
runs-on: ubuntu-latest # Default to ubuntu-latest
timeout-minutes: 15 # Always set a timeout
steps:
- uses: actions/checkout@v4 # Always pin to major version
Trigger: pull_request + push to main Jobs: lint, test (parallel when possible) Key features: dependency caching, matrix testing for multiple versions
Trigger: push to main (or release tags) Jobs: test → build → deploy (sequential with needs) Key features: environment protection, secrets for credentials, status checks
Trigger: push tags matching v* or workflow_dispatch Jobs: test → build → publish → create GitHub Release Key features: changelog generation, artifact upload, npm/PyPI/Docker publish
Trigger: schedule with cron expression Jobs: single job with the task Key features: workflow_dispatch for manual trigger too, failure notifications
Trigger: pull_request + schedule (weekly) Jobs: dependency audit, SAST, secret scanning Key features: SARIF upload to GitHub Security tab, fail on critical
Trigger: push to main + tags Jobs: build → push to registry Key features: multi-platform builds, layer caching, image tagging strategy
| Action | Purpose |
|---|---|
actions/checkout@v4 | Clone repository |
actions/setup-node@v4 | Node.js with caching |
actions/setup-python@v5 | Python with caching |
actions/setup-go@v5 | Go with caching |
actions/setup-java@v4 | Java/Kotlin |
dtolnay/rust-toolchain@stable |
| Action | Purpose |
|---|---|
docker/build-push-action@v6 | Docker multi-platform builds |
docker/login-action@v3 | Docker registry authentication |
aws-actions/configure-aws-credentials@v4 | AWS authentication |
google-github-actions/auth@v2 | GCP authentication |
azure/login@v2 | Azure authentication |
cloudflare/wrangler-action@v3 |
| Action | Purpose |
|---|---|
github/codeql-action/analyze@v3 | CodeQL SAST scanning |
aquasecurity/trivy-action@master | Container vulnerability scan |
codecov/codecov-action@v4 | Coverage upload |
actions/dependency-review-action@v4 | Dependency audit on PRs |
| Action | Purpose |
|---|---|
actions/cache@v4 | Generic caching |
actions/upload-artifact@v4 | Store build artifacts |
actions/download-artifact@v4 | Retrieve artifacts between jobs |
softprops/action-gh-release@v2 | Create GitHub Releases |
slackapi/slack-github-action@v2 | Slack notifications |
peter-evans/create-pull-request@v7 |
permissions at workflow or job level@v4 not @main or full SHA for readabilityecho ${{ secrets.X }}workflow_dispatch, validate input values${{ github.event.*.body }} directly in run: — pass via environment variables${{ secrets.GITHUB_TOKEN }} over PATs when possible# WRONG - script injection vulnerability
- run: echo "${{ github.event.issue.title }}"
# CORRECT - pass through environment variable
- run: echo "$ISSUE_TITLE"
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm' # or 'yarn' or 'pnpm'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip' # or 'poetry' or 'pipenv'
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
strategy:
matrix:
node-version: [18, 20, 22]
fail-fast: false
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [18, 20]
exclude:
- os: windows-latest
node-version: 18
| Schedule | Cron |
|---|---|
| Every hour | 0 * * * * |
| Daily at midnight UTC | 0 0 * * * |
| Weekdays at 9am UTC | 0 9 * * 1-5 |
| Weekly on Sunday | 0 0 * * 0 |
| Monthly 1st | 0 0 1 * * |
After creating the workflow file, provide:
When the user asks for something generic like "set up CI/CD", create a single workflow with multiple jobs:
jobs:
lint: # Fast feedback
test: # Core validation
build: # Ensure it compiles/bundles
needs: [lint, test]
deploy: # Only after everything passes
needs: build
if: github.ref == 'refs/heads/main'
Keep workflows focused. Prefer one workflow per concern over one massive workflow, unless the jobs are tightly coupled.
Weekly Installs
106
Repository
GitHub Stars
23.4K
First Seen
Feb 10, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykPass
Installed on
codex102
gemini-cli101
opencode101
kimi-cli100
amp100
github-copilot100
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
133,300 周安装
| Rust toolchain |
ruby/setup-ruby@v1 | Ruby with bundler cache |
actions/setup-dotnet@v4 | .NET SDK |
| Cloudflare Workers deploy |
amondnet/vercel-action@v25 | Vercel deployment |
| Automated PR creation |
concurrency to prevent parallel deploys