github-project-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Project Automation
GitHub 项目自动化
Status: Production Ready ✅
Last Updated: 2025-11-06
Dependencies: None (git and gh CLI recommended)
Latest Versions: actions/checkout@v4.2.2, actions/setup-node@v4.1.0, github/codeql-action@v3.27.4
状态:已就绪可用于生产环境 ✅
最后更新:2025-11-06
依赖:无(推荐使用git和gh CLI)
最新版本:actions/checkout@v4.2.2, actions/setup-node@v4.1.0, github/codeql-action@v3.27.4
Quick Start (15 Minutes)
快速开始(15分钟)
1. Choose Your Framework
1. 选择你的框架
Select the workflow template that matches your project:
bash
undefined选择与项目匹配的工作流模板:
bash
undefinedFor React/Vite projects
适用于React/Vite项目
cp templates/workflows/ci-react.yml .github/workflows/ci.yml
cp templates/workflows/ci-react.yml .github/workflows/ci.yml
For Node.js libraries (matrix testing)
适用于Node.js库(矩阵测试)
cp templates/workflows/ci-node.yml .github/workflows/ci.yml
cp templates/workflows/ci-node.yml .github/workflows/ci.yml
For Python projects
适用于Python项目
cp templates/workflows/ci-python.yml .github/workflows/ci.yml
cp templates/workflows/ci-python.yml .github/workflows/ci.yml
For Cloudflare Workers
适用于Cloudflare Workers
cp templates/workflows/ci-cloudflare-workers.yml .github/workflows/deploy.yml
cp templates/workflows/ci-cloudflare-workers.yml .github/workflows/deploy.yml
For basic projects (any framework)
适用于基础项目(任意框架)
cp templates/workflows/ci-basic.yml .github/workflows/ci.yml
**Why this matters:**
- Pre-validated YAML prevents syntax errors
- SHA-pinned actions for security
- Explicit runner versions (ubuntu-24.04)
- All 8 GitHub Actions errors preventedcp templates/workflows/ci-basic.yml .github/workflows/ci.yml
**为什么这很重要**:
- 预验证的YAML可避免语法错误
- 基于SHA固定Action版本以保障安全
- 明确指定运行器版本(ubuntu-24.04)
- 可预防全部8类GitHub Actions错误2. Add Issue Templates
2. 添加Issue模板
bash
undefinedbash
undefinedCreate directory structure
创建目录结构
mkdir -p .github/ISSUE_TEMPLATE
mkdir -p .github/ISSUE_TEMPLATE
Copy YAML templates (with validation)
复制带验证功能的YAML模板
cp templates/issue-templates/bug_report.yml .github/ISSUE_TEMPLATE/
cp templates/issue-templates/feature_request.yml .github/ISSUE_TEMPLATE/
**Why YAML over Markdown:**
- Required field validation (Error #12 prevented)
- Consistent data structure
- Better user experience
- No incomplete issuescp templates/issue-templates/bug_report.yml .github/ISSUE_TEMPLATE/
cp templates/issue-templates/feature_request.yml .github/ISSUE_TEMPLATE/
**为什么选择YAML而非Markdown**:
- 支持必填字段验证(预防第12类错误)
- 数据结构一致
- 更好的用户体验
- 避免不完整的Issue3. Enable Security Scanning
3. 启用安全扫描
bash
undefinedbash
undefinedCodeQL for code analysis
用于代码分析的CodeQL
cp templates/workflows/security-codeql.yml .github/workflows/codeql.yml
cp templates/workflows/security-codeql.yml .github/workflows/codeql.yml
Dependabot for dependency updates
用于依赖更新的Dependabot
cp templates/security/dependabot.yml .github/dependabot.yml
**CRITICAL:**
- CodeQL requires specific permissions (security-events: write)
- Dependabot has 10 PR limit per ecosystem
- Both must run on Dependabot PRs (Error #13 prevention)
---cp templates/security/dependabot.yml .github/dependabot.yml
**关键注意事项**:
- CodeQL需要特定权限(security-events: write)
- Dependabot每个生态系统最多生成10个PR
- 两者都必须在Dependabot PR上运行(预防第13类错误)
---The 5-Step Complete Setup Process
五步完整设置流程
Step 1: Repository Structure
步骤1:仓库结构
Create the standard GitHub automation directory structure:
bash
undefined创建标准的GitHub自动化目录结构:
bash
undefinedCreate all required directories
创建所有必需的目录
mkdir -p .github/{workflows,ISSUE_TEMPLATE}
mkdir -p .github/{workflows,ISSUE_TEMPLATE}
Verify structure
验证结构
tree .github/
tree .github/
.github/
.github/
├── workflows/ # GitHub Actions workflows
├── workflows/ # GitHub Actions工作流
├── ISSUE_TEMPLATE/ # Issue templates
├── ISSUE_TEMPLATE/ # Issue模板
└── dependabot.yml # Dependabot config (root of .github/)
└── dependabot.yml # Dependabot配置文件(位于.github/根目录)
**Key Points:**
- workflows/ is plural
- ISSUE_TEMPLATE/ is singular (legacy naming)
- dependabot.yml goes in .github/, NOT workflows/
**要点**:
- workflows/为复数形式
- ISSUE_TEMPLATE/为单数形式(历史命名规则)
- dependabot.yml需放在.github/目录下,而非workflows/内Step 2: Select Workflow Templates
步骤2:选择工作流模板
Choose workflows based on your project needs:
Continuous Integration (pick ONE):
- - Generic test/lint/build (all frameworks)
ci-basic.yml - - Node.js with matrix testing (18, 20, 22)
ci-node.yml - - Python with matrix testing (3.10, 3.11, 3.12)
ci-python.yml - - React/TypeScript with type checking
ci-react.yml
Deployment (optional):
5. - Deploy to Cloudflare Workers
ci-cloudflare-workers.ymlSecurity (recommended):
6. - Code scanning
7. - Dependency updates
security-codeql.ymldependabot.ymlCopy selected templates:
bash
undefined根据项目需求选择工作流:
持续集成(选择其一):
- - 通用测试/代码检查/构建模板(支持所有框架)
ci-basic.yml - - 带矩阵测试的Node.js模板(支持18、20、22版本)
ci-node.yml - - 带矩阵测试的Python模板(支持3.10、3.11、3.12版本)
ci-python.yml - - 带类型检查的React/TypeScript模板
ci-react.yml
部署(可选):
5. - 部署至Cloudflare Workers
ci-cloudflare-workers.yml安全(推荐):
6. - 代码扫描
7. - 依赖更新
security-codeql.ymldependabot.yml复制选定的模板:
bash
undefinedExample: React app with security
示例:带安全功能的React应用
cp templates/workflows/ci-react.yml .github/workflows/ci.yml
cp templates/workflows/security-codeql.yml .github/workflows/codeql.yml
cp templates/security/dependabot.yml .github/dependabot.yml
undefinedcp templates/workflows/ci-react.yml .github/workflows/ci.yml
cp templates/workflows/security-codeql.yml .github/workflows/codeql.yml
cp templates/security/dependabot.yml .github/dependabot.yml
undefinedStep 3: Configure Secrets (if deploying)
步骤3:配置密钥(若需部署)
For deployment workflows (Cloudflare, AWS, etc.), add secrets:
bash
undefined对于部署类工作流(如Cloudflare、AWS等),添加密钥:
bash
undefinedUsing gh CLI
使用gh CLI
gh secret set CLOUDFLARE_API_TOKEN
gh secret set CLOUDFLARE_API_TOKEN
Paste your token when prompted
提示时粘贴你的令牌
Verify
验证
gh secret list
**Critical Syntax:**
```yamlgh secret list
**关键语法**:
```yaml✅ CORRECT
✅ 正确写法
env:
API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
env:
API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
❌ WRONG - Missing double braces
❌ 错误写法 - 缺少双大括号
env:
API_TOKEN: $secrets.CLOUDFLARE_API_TOKEN
Prevents Error #6 (secrets syntax).env:
API_TOKEN: $secrets.CLOUDFLARE_API_TOKEN
可预防第6类错误(密钥语法错误)。Step 4: Add Issue/PR Templates
步骤4:添加Issue/PR模板
Issue templates (YAML format):
bash
cp templates/issue-templates/bug_report.yml .github/ISSUE_TEMPLATE/
cp templates/issue-templates/feature_request.yml .github/ISSUE_TEMPLATE/PR template (Markdown format):
bash
cp templates/pr-templates/PULL_REQUEST_TEMPLATE.md .github/Why separate formats:
- Issue templates: YAML for validation
- PR template: Markdown (GitHub limitation)
Issue模板(YAML格式):
bash
cp templates/issue-templates/bug_report.yml .github/ISSUE_TEMPLATE/
cp templates/issue-templates/feature_request.yml .github/ISSUE_TEMPLATE/PR模板(Markdown格式):
bash
cp templates/pr-templates/PULL_REQUEST_TEMPLATE.md .github/为什么使用不同格式:
- Issue模板:使用YAML以支持验证
- PR模板:使用Markdown(GitHub限制)
Step 5: Customize for Your Project
步骤5:针对你的项目进行自定义
Required customizations:
-
Update usernames/emails:yaml
# In issue templates assignees: - jezweb # ← Change to your GitHub username # In dependabot.yml reviewers: - "jezweb" # ← Change to your username -
Adjust languages (CodeQL):yaml
# In security-codeql.yml matrix: language: ['javascript-typescript'] # ← Add your languages # Options: c-cpp, csharp, go, java-kotlin, python, ruby, swift -
Update package manager (Dependabot):yaml
# In dependabot.yml - package-ecosystem: "npm" # ← Change if using yarn/pnpm/pip/etc -
Set deployment URL (Cloudflare):yaml
# In ci-cloudflare-workers.yml echo "Worker URL: https://your-worker.your-subdomain.workers.dev" # ← Update with your actual Worker URL
必需的自定义项:
-
更新用户名/邮箱:yaml
# 在Issue模板中 assignees: - jezweb # ← 修改为你的GitHub用户名 # 在dependabot.yml中 reviewers: - "jezweb" # ← 修改为你的用户名 -
调整语言(CodeQL):yaml
# 在security-codeql.yml中 matrix: language: ['javascript-typescript'] # ← 添加你的项目使用的语言 # 可选值:c-cpp, csharp, go, java-kotlin, python, ruby, swift -
更新包管理器(Dependabot):yaml
# 在dependabot.yml中 - package-ecosystem: "npm" # ← 若使用yarn/pnpm/pip等请修改 -
设置部署URL(Cloudflare):yaml
# 在ci-cloudflare-workers.yml中 echo "Worker URL: https://your-worker.your-subdomain.workers.dev" # ← 使用你的实际Worker URL进行更新
Critical Rules
关键规则
Always Do
务必遵守
✅ Pin actions to SHA, not @latest
yaml
undefined✅ 将Action固定到SHA,而非@latest
yaml
undefined✅ CORRECT
✅ 正确写法
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
❌ WRONG
❌ 错误写法
- uses: actions/checkout@latest
✅ **Use explicit runner versions**
```yaml- uses: actions/checkout@latest
✅ **使用明确的运行器版本**
```yaml✅ CORRECT
✅ 正确写法
runs-on: ubuntu-24.04 # Locked to specific LTS
runs-on: ubuntu-24.04 # 锁定到特定LTS版本
❌ RISKY
❌ 存在风险
runs-on: ubuntu-latest # Changes over time
✅ **Include secrets in context syntax**
```yamlruns-on: ubuntu-latest # 版本会随时间变化
✅ **在上下文语法中包含密钥**
```yaml✅ CORRECT
✅ 正确写法
${{ secrets.API_TOKEN }}
${{ secrets.API_TOKEN }}
❌ WRONG
❌ 错误写法
$secrets.API_TOKEN
✅ **Validate YAML before committing**
```bash$secrets.API_TOKEN
✅ **提交前验证YAML**
```bashUse yamllint or GitHub's workflow validator
使用yamllint或GitHub的工作流验证工具
yamllint .github/workflows/*.yml
✅ **Test workflows on feature branch first**
```bash
git checkout -b test/github-actionsyamllint .github/workflows/*.yml
✅ **先在功能分支测试工作流**
```bash
git checkout -b test/github-actionsPush and verify CI runs before merging to main
推送代码并验证CI运行正常后再合并到主分支
undefinedundefinedNever Do
切勿执行
❌ Don't use @latest for action versions
- Breaks without warning when actions update
- Security risk (unvetted versions auto-adopted)
❌ Don't hardcode secrets in workflows
yaml
undefined❌ 不要对Action版本使用@latest
- Action更新时会无预警地导致工作流中断
- 安全风险(自动采用未经验证的版本)
❌ 不要在工作流中硬编码密钥
yaml
undefined❌ NEVER DO THIS
❌ 绝对不要这样做
env:
API_TOKEN: "sk_live_abc123..." # Secret exposed in repo!
❌ **Don't skip build steps for compiled languages (CodeQL)**
```yamlenv:
API_TOKEN: "sk_live_abc123..." # 密钥会在仓库中暴露!
❌ **不要跳过编译型语言的构建步骤(CodeQL)**
```yaml❌ WRONG - CodeQL fails for Java without build
❌ 错误写法 - 没有构建步骤的Java项目CodeQL会失败
- name: Perform CodeQL Analysis # No .class files to analyze
- name: Perform CodeQL Analysis # 没有可分析的.class文件
✅ CORRECT - Include build
✅ 正确写法 - 包含构建步骤
- name: Build project run: ./mvnw clean install
- name: Perform CodeQL Analysis # Now has .class files
❌ **Don't ignore devDependencies in Dependabot**
- DevDependencies run during build, can execute malicious code
- Include both prod and dev dependencies
❌ **Don't use single ISSUE_TEMPLATE.md file**- name: Build project run: ./mvnw clean install
- name: Perform CodeQL Analysis # 现在有可分析的.class文件
❌ **不要忽略Dependabot中的devDependencies**
- devDependencies会在构建阶段运行,可能执行恶意代码
- 需同时包含生产和开发依赖
❌ **不要使用单个ISSUE_TEMPLATE.md文件**❌ OLD WAY
❌ 旧方式
.github/ISSUE_TEMPLATE.md
.github/ISSUE_TEMPLATE.md
✅ NEW WAY
✅ 新方式
.github/ISSUE_TEMPLATE/
bug_report.yml
feature_request.yml
---.github/ISSUE_TEMPLATE/
bug_report.yml
feature_request.yml
---Known Issues Prevention
已知问题预防
This skill prevents 18 documented issues:
本技能可预防18类已记录的问题:
Issue #1: YAML Indentation Errors
问题1:YAML缩进错误
Error:
Source: Stack Overflow (most common GitHub Actions error)
Why It Happens: Spaces vs tabs, missing spaces after colons, inconsistent indentation
Prevention: Use skill templates with validated 2-space indentation
workflow file is invalid. mapping values are not allowed in this context错误信息:
来源:Stack Overflow(最常见的GitHub Actions错误)
原因:空格与制表符混用、冒号后缺少空格、缩进不一致
预防方案:使用经过验证的2空格缩进模板
workflow file is invalid. mapping values are not allowed in this contextIssue #2: Missing run
or uses
Field
runuses问题2:缺少run
或uses
字段
runusesError:
Source: GitHub Actions Error Logs
Why It Happens: Empty step definition, forgetting to add command
Prevention: Templates include complete step definitions
Error: Step must have a run or uses key错误信息:
来源:GitHub Actions错误日志
原因:步骤定义为空、忘记添加命令
预防方案:模板包含完整的步骤定义
Error: Step must have a run or uses keyIssue #3: Action Version Pinning Issues
问题3:Action版本固定问题
Error: Workflow breaks unexpectedly after action updates
Source: GitHub Security Best Practices 2025
Why It Happens: Using or instead of specific SHA
Prevention: All templates pin to SHA with version comment
@latest@v4错误信息:Action更新后工作流意外中断
来源:GitHub 2025安全最佳实践
原因:使用或而非特定SHA
预防方案:所有模板均通过SHA固定版本并附带版本注释
@latest@v4Issue #4: Incorrect Runner Version
问题4:运行器版本不正确
Error: Unexpected environment changes, compatibility issues
Source: CI/CD Troubleshooting Guides
Why It Happens: changed from 22.04 → 24.04 in 2024
Prevention: Templates use explicit
ubuntu-latestubuntu-24.04错误信息:环境意外变更、兼容性问题
来源:CI/CD排查指南
原因:2024年从22.04更新为24.04
预防方案:模板使用明确的
ubuntu-latestubuntu-24.04Issue #5: Multiple Keys with Same Name
问题5:存在重名字段
Error:
Source: YAML Parser Updates
Why It Happens: Copy-paste errors, duplicate job/step names
Prevention: Templates use unique, descriptive naming
duplicate key found in mapping错误信息:
来源:YAML解析器更新
原因:复制粘贴错误、作业/步骤名称重复
预防方案:模板使用唯一且具有描述性的命名
duplicate key found in mappingIssue #6: Secrets Not Available
问题6:密钥不可用
Error: or empty variable
Source: GitHub Actions Debugging Guides
Why It Happens: Wrong syntax ( instead of )
Prevention: Templates demonstrate correct context syntax
Secret not found$secrets.NAME${{ secrets.NAME }}错误信息:或变量为空
来源:GitHub Actions调试指南
原因:语法错误(使用而非)
预防方案:模板展示正确的上下文语法
Secret not found$secrets.NAME${{ secrets.NAME }}Issue #7: Matrix Strategy Errors
问题7:矩阵策略错误
Error: Matrix doesn't expand, tests skipped
Source: Troubleshooting Guides
Why It Happens: Invalid matrix config, wrong variable reference
Prevention: Templates include working matrix examples
错误信息:矩阵未展开、测试被跳过
来源:排查指南
原因:矩阵配置无效、变量引用错误
预防方案:模板包含可正常运行的矩阵示例
Issue #8: Context Syntax Errors
问题8:上下文语法错误
Error: Variables not interpolated, empty values
Source: GitHub Actions Docs
Why It Happens: Forgetting wrapper
Prevention: Templates show all context patterns
${{ }}错误信息:变量未被插值、值为空
来源:GitHub Actions文档
原因:忘记添加包裹
预防方案:模板展示所有上下文模式
${{ }}Issue #9: Overly Complex Templates
问题9:模板过于复杂
Error: Contributors ignore template, incomplete issues
Source: GitHub Best Practices
Why It Happens: 20+ fields, asking irrelevant details
Prevention: Skill templates are minimal (5-8 fields max)
错误信息:贡献者忽略模板、Issue不完整
来源:GitHub最佳实践
原因:包含20+个字段、询问无关信息
预防方案:技能模板保持精简(最多5-8个字段)
Issue #10: Generic Prompts Without Context
问题10:通用提示缺少上下文
Error: Vague bug reports, hard to reproduce
Source: Template Best Practices
Why It Happens: No guidance on what info is needed
Prevention: Templates include specific placeholders
错误信息:Bug报告模糊、难以复现
来源:模板最佳实践
原因:未说明需要提供哪些信息
预防方案:模板包含特定占位符
Issue #11: Multiple Template Confusion
问题11:多模板混淆
Error: Users don't know which template to use
Source: GitHub Docs
Why It Happens: Using single file
Prevention: Proper directory with config.yml
ISSUE_TEMPLATE.mdISSUE_TEMPLATE/错误信息:用户不知道使用哪个模板
来源:GitHub文档
原因:使用单个文件
预防方案:使用标准的目录及config.yml
ISSUE_TEMPLATE.mdISSUE_TEMPLATE/Issue #12: Missing Required Fields
问题12:缺少必填字段
Error: Incomplete issues, missing critical info
Source: Community Feedback
Why It Happens: Markdown templates don't validate
Prevention: YAML templates with
required: true错误信息:Issue不完整、缺少关键信息
来源:社区反馈
原因:Markdown模板不支持验证
预防方案:使用带有的YAML模板
required: trueIssue #13: CodeQL Not Running on Dependabot PRs
问题13:CodeQL未在Dependabot PR上运行
Error: Security scans skipped on dependency updates
Source: GitHub Community Discussion #121836
Why It Happens: Default trigger limitations
Prevention: Templates include
push: branches: [dependabot/**]错误信息:依赖更新时跳过安全扫描
来源:GitHub社区讨论#121836
原因:默认触发条件限制
预防方案:模板包含
push: branches: [dependabot/**]Issue #14: Branch Protection Blocking All PRs
问题14:分支保护阻止所有PR
Error: Legitimate PRs blocked, development stalled
Source: Security Alerts Guide
Why It Happens: Over-restrictive alert policies
Prevention: Reference docs explain proper scoping
错误信息:合法PR被阻止、开发停滞
来源:安全警报指南
原因:警报策略过于严格
预防方案:参考文档说明正确的范围设置
Issue #15: Compiled Language CodeQL Setup
问题15:编译型语言CodeQL设置错误
Error:
Source: CodeQL Documentation
Why It Happens: Missing build steps for Java/C++/C#
Prevention: Templates include build examples
No code found to analyze错误信息:
来源:CodeQL文档
原因:Java/C++/C#项目缺少构建步骤
预防方案:模板包含构建示例
No code found to analyzeIssue #16: Development Dependencies Ignored
问题16:开发依赖被忽略
Error: Vulnerable devDependencies not scanned
Source: Security Best Practices
Why It Happens: Thinking devDependencies don't matter
Prevention: Templates scan all dependencies
错误信息:易受攻击的devDependencies未被扫描
来源:安全最佳实践
原因:认为devDependencies无关紧要
预防方案:模板扫描所有依赖
Issue #17: Dependabot Alert Limit
问题17:Dependabot警报限制
Error: Only 10 alerts auto-fixed, others queued
Source: GitHub Docs (hard limit)
Why It Happens: GitHub limits 10 open PRs per ecosystem
Prevention: Templates document limit and workaround
错误信息:仅10个警报被自动修复,其余排队
来源:GitHub文档(硬限制)
原因:GitHub每个生态系统最多允许10个开放PR
预防方案:模板记录该限制及解决方法
Issue #18: Workflow Duplication
问题18:工作流重复
Error: Wasted CI minutes, maintenance overhead
Source: DevSecOps Guides
Why It Happens: Separate workflows for CI/CodeQL/dependency review
Prevention: Templates offer integrated option
See: for detailed error documentation with examples
references/common-errors.md错误信息:浪费CI时长、维护开销大
来源:DevSecOps指南
原因:为CI/CodeQL/依赖审查分别创建工作流
预防方案:模板提供集成选项
参考:包含所有错误的详细文档及示例
references/common-errors.mdConfiguration Files Reference
配置文件参考
dependabot.yml (Full Example)
dependabot.yml(完整示例)
yaml
version: 2
updates:
# npm dependencies (including devDependencies)
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
timezone: "Australia/Sydney"
open-pull-requests-limit: 10 # GitHub hard limit
reviewers:
- "jezweb"
labels:
- "dependencies"
- "npm"
commit-message:
prefix: "chore"
prefix-development: "chore"
include: "scope"
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
labels:
- "dependencies"
- "github-actions"Why these settings:
- Weekly schedule reduces noise vs daily
- 10 PR limit matches GitHub maximum
- Includes devDependencies (Error #16 prevention)
- Reviewers auto-assigned for faster triage
- Conventional commit prefixes (chore: for deps)
yaml
version: 2
updates:
# npm依赖(包括devDependencies)
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
timezone: "Australia/Sydney"
open-pull-requests-limit: 10 # GitHub硬限制
reviewers:
- "jezweb"
labels:
- "dependencies"
- "npm"
commit-message:
prefix: "chore"
prefix-development: "chore"
include: "scope"
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
labels:
- "dependencies"
- "github-actions"这些设置的原因:
- 每周调度比每日调度减少干扰
- 10个PR限制与GitHub最大值匹配
- 包含devDependencies(预防第16类错误)
- 自动分配审核人以加快处理速度
- 使用约定式提交前缀(deps更新使用chore:)
CodeQL Workflow (security-codeql.yml)
CodeQL工作流(security-codeql.yml)
yaml
name: CodeQL Security Scan
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
- cron: '0 0 * * 0' # Weekly on Sundays
jobs:
analyze:
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
security-events: write # REQUIRED for CodeQL
strategy:
fail-fast: false
matrix:
language: ['javascript-typescript'] # Add your languages
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Initialize CodeQL
uses: github/codeql-action/init@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f
with:
languages: ${{ matrix.language }}
# For compiled languages, add build here
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ea9e4e37992a54ee68a9622e985e60c8e8f12d9fCritical permissions:
- is REQUIRED for CodeQL uploads
security-events: write - Without it, workflow fails silently
yaml
name: CodeQL Security Scan
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
- cron: '0 0 * * 0' # 每周日运行
jobs:
analyze:
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
security-events: write # CodeQL必需
strategy:
fail-fast: false
matrix:
language: ['javascript-typescript'] # 添加你的项目语言
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Initialize CodeQL
uses: github/codeql-action/init@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f
with:
languages: ${{ matrix.language }}
# 对于编译型语言,在此添加构建步骤
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f关键权限:
- 是CodeQL上传结果必需的权限
security-events: write - 缺少该权限会导致工作流静默失败
Common Patterns
常见模式
Pattern 1: Multi-Framework Matrix Testing
模式1:多框架矩阵测试
Use for libraries that support multiple Node.js/Python versions:
yaml
strategy:
matrix:
node-version: [18, 20, 22] # LTS versions
fail-fast: false # Test all versions even if one fails
steps:
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: ${{ matrix.node-version }}
cache: 'npm' # Cache dependencies for speed
- run: npm ci # Use ci (not install) for reproducible builds
- run: npm testWhen to use: Libraries, CLI tools, packages with broad version support
适用于支持多个Node.js/Python版本的库:
yaml
strategy:
matrix:
node-version: [18, 20, 22] # LTS版本
fail-fast: false # 即使一个版本失败,仍测试所有版本
steps:
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: ${{ matrix.node-version }}
cache: 'npm' # 缓存依赖以提升速度
- run: npm ci # 使用ci而非install以实现可复现的构建
- run: npm test适用场景:库、CLI工具、支持多版本的包
Pattern 2: Conditional Deployment
模式2:条件部署
Deploy only on push to main (not PRs):
yaml
jobs:
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- run: npx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}When to use: Production deployments, avoiding test deployments from PRs
仅在推送到主分支时部署(PR不触发):
yaml
jobs:
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- run: npx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}适用场景:生产环境部署、避免PR触发测试部署
Pattern 3: Artifact Upload/Download
模式3:制品上传/下载
Share build outputs between jobs:
yaml
jobs:
build:
steps:
- run: npm run build
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: build-output
path: dist/
retention-days: 7
deploy:
needs: build
steps:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: build-output
path: dist/
- run: # Deploy from dist/When to use: Separating build and deployment, sharing test results
在作业之间共享构建输出:
yaml
jobs:
build:
steps:
- run: npm run build
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: build-output
path: dist/
retention-days: 7
deploy:
needs: build
steps:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: build-output
path: dist/
- run: # 从dist/目录部署适用场景:分离构建与部署、共享测试结果
Using Bundled Resources
使用捆绑资源
Scripts (scripts/)
脚本(scripts/)
Coming in Phase 3 - Automation scripts for common tasks:
- - Interactive setup wizard
setup-github-project.sh - - YAML validation before commit
validate-workflows.sh - - Auto-generate from git log
generate-codeowners.sh - - Update existing projects
sync-templates.sh
Example Usage:
bash
./scripts/setup-github-project.sh react第三阶段即将推出 - 用于常见任务的自动化脚本:
- - 交互式设置向导
setup-github-project.sh - - 提交前YAML验证
validate-workflows.sh - - 从git日志自动生成
generate-codeowners.sh - - 更新现有项目
sync-templates.sh
示例用法:
bash
./scripts/setup-github-project.sh reactPrompts for project details, generates .github/ structure
提示输入项目详情,生成.github/结构
undefinedundefinedReferences (references/)
参考资料(references/)
Load when needed for detailed error resolution:
- - All 18 errors with solutions (complete)
references/common-errors.md - - Complete Actions API (Phase 2)
references/github-actions-reference.md - - YAML syntax guide (Phase 2)
references/workflow-syntax.md - - Dependabot deep-dive (Phase 2)
references/dependabot-guide.md - - CodeQL configuration (Phase 2)
references/codeql-guide.md - - Secrets best practices (Phase 2)
references/secrets-management.md - - Matrix patterns (Phase 2)
references/matrix-strategies.md
When Claude should load these: When user encounters specific errors, needs deep configuration, or troubleshooting complex scenarios
按需查阅以解决具体错误:
- - 包含所有18类错误及解决方案(已完成)
references/common-errors.md - - 完整的Actions API(第二阶段)
references/github-actions-reference.md - - YAML语法指南(第二阶段)
references/workflow-syntax.md - - Dependabot深度指南(第二阶段)
references/dependabot-guide.md - - CodeQL配置指南(第二阶段)
references/codeql-guide.md - - 密钥最佳实践(第二阶段)
references/secrets-management.md - - 矩阵模式(第二阶段)
references/matrix-strategies.md
Claude应在何时加载这些资料:当用户遇到特定错误、需要深度配置或排查复杂场景时
Templates (templates/)
模板(templates/)
Complete collection - 45+ files organized by type:
Workflows (12 templates):
- Phase 1 (complete): ci-basic, ci-node, ci-python, ci-react, ci-cloudflare-workers, security-codeql
- Phase 2: ci-matrix, cd-production, release, pr-checks, scheduled-maintenance, security-dependency-review
Issue Templates (4 templates):
- Phase 1 (complete): bug_report.yml, feature_request.yml
- Phase 2: documentation.yml, config.yml
PR Templates (3 templates):
- Phase 1 (complete): PULL_REQUEST_TEMPLATE.md
- Phase 2: feature.md, bugfix.md
Security (3 templates):
- Phase 1 (complete): dependabot.yml
- Phase 2: SECURITY.md, codeql-config.yml
Misc (2 templates):
- Phase 2: CODEOWNERS, FUNDING.yml
完整集合 - 45+个按类型组织的文件:
工作流(12个模板):
- 第一阶段(已完成):ci-basic、ci-node、ci-python、ci-react、ci-cloudflare-workers、security-codeql
- 第二阶段:ci-matrix、cd-production、release、pr-checks、scheduled-maintenance、security-dependency-review
Issue模板(4个模板):
- 第一阶段(已完成):bug_report.yml、feature_request.yml
- 第二阶段:documentation.yml、config.yml
PR模板(3个模板):
- 第一阶段(已完成):PULL_REQUEST_TEMPLATE.md
- 第二阶段:feature.md、bugfix.md
安全(3个模板):
- 第一阶段(已完成):dependabot.yml
- 第二阶段:SECURITY.md、codeql-config.yml
其他(2个模板):
- 第二阶段:CODEOWNERS、FUNDING.yml
Integration with Existing Skills
与现有技能集成
cloudflare-worker-base → Add CI/CD
cloudflare-worker-base → 添加CI/CD
When user creates new Worker project:
bash
undefined当用户创建新的Worker项目时:
bash
undefinedUser: "Create Cloudflare Worker with CI/CD"
用户:"创建带CI/CD的Cloudflare Worker"
This skill runs AFTER cloudflare-worker-base
本技能在cloudflare-worker-base之后运行
cp templates/workflows/ci-cloudflare-workers.yml .github/workflows/deploy.yml
cp templates/workflows/ci-cloudflare-workers.yml .github/workflows/deploy.yml
Configure secrets
配置密钥
gh secret set CLOUDFLARE_API_TOKEN
**Result**: New Worker with automated deployment on push to maingh secret set CLOUDFLARE_API_TOKEN
**结果**:新的Worker项目在推送到主分支时自动部署project-planning → Generate Automation
project-planning → 生成自动化配置
When user uses project-planning skill:
bash
undefined当用户使用project-planning技能时:
bash
undefinedUser: "Plan new React app with GitHub automation"
用户:"规划带GitHub自动化的新React应用"
project-planning generates IMPLEMENTATION_PHASES.md
project-planning生成IMPLEMENTATION_PHASES.md
Then this skill sets up GitHub automation
然后本技能设置GitHub自动化
cp templates/workflows/ci-react.yml .github/workflows/ci.yml
cp templates/issue-templates/*.yml .github/ISSUE_TEMPLATE/
**Result**: Planned project with complete GitHub automationcp templates/workflows/ci-react.yml .github/workflows/ci.yml
cp templates/issue-templates/*.yml .github/ISSUE_TEMPLATE/
**结果**:已规划的项目包含完整的GitHub自动化配置open-source-contributions → Setup Contributor Experience
open-source-contributions → 搭建贡献者体验
When preparing project for open source:
bash
undefined当准备将项目开源时:
bash
undefinedUser: "Prepare repo for open source contributions"
用户:"准备仓库以接受开源贡献"
open-source-contributions skill handles CONTRIBUTING.md
open-source-contributions技能处理CONTRIBUTING.md
This skill adds issue templates and CODEOWNERS
本技能添加Issue模板和CODEOWNERS
cp templates/issue-templates/*.yml .github/ISSUE_TEMPLATE/
cp templates/misc/CODEOWNERS .github/
**Result**: Contributor-friendly repository
---cp templates/issue-templates/*.yml .github/ISSUE_TEMPLATE/
cp templates/misc/CODEOWNERS .github/
**结果**:对贡献者友好的仓库
---Advanced Topics
高级主题
Integrating with GitHub Projects v2
与GitHub Projects v2集成
Status: Researched, not implemented (see )
/planning/github-projects-poc-findings.mdWhy separate skill: Complex GraphQL API, ID management, niche use case
When to consider: Team projects needing automated board management
状态:已调研,未实现(查看)
/planning/github-projects-poc-findings.md为什么作为独立技能:复杂的GraphQL API、ID管理、小众使用场景
何时考虑使用:需要自动化看板管理的团队项目
Custom Workflow Composition
自定义工作流组合
Combining workflows for efficiency:
yaml
undefined组合工作流以提升效率:
yaml
undefinedOption A: Separate workflows (easier maintenance)
选项A:分离的工作流(更易维护)
.github/workflows/
ci.yml # Test and build
codeql.yml # Security scanning
deploy.yml # Production deployment
.github/workflows/
ci.yml # 测试与构建
codeql.yml # 安全扫描
deploy.yml # 生产部署
Option B: Integrated workflow (fewer CI minutes)
选项B:集成式工作流(减少CI时长)
.github/workflows/
main.yml # All-in-one: test, scan, deploy
**Trade-off**: Separate = clearer, Integrated = faster (Error #18 prevention).github/workflows/
main.yml # 一体化:测试、扫描、部署
**权衡**:分离式=更清晰,集成式=更快(预防第18类错误)Multi-Environment Deployments
多环境部署
Deploy to staging and production:
yaml
jobs:
deploy-staging:
if: github.ref == 'refs/heads/develop'
steps:
- run: npx wrangler deploy --env staging
deploy-production:
if: github.ref == 'refs/heads/main'
steps:
- run: npx wrangler deploy --env productionRequires: Wrangler environments configured in
wrangler.jsonc部署到预发布和生产环境:
yaml
jobs:
deploy-staging:
if: github.ref == 'refs/heads/develop'
steps:
- run: npx wrangler deploy --env staging
deploy-production:
if: github.ref == 'refs/heads/main'
steps:
- run: npx wrangler deploy --env production要求:Wrangler环境需在中配置
wrangler.jsoncDependencies
依赖项
Required:
- Git 2.0+ - Version control
- GitHub CLI (gh) 2.0+ - Secret management, PR creation (optional but recommended)
Optional:
- yamllint 1.20+ - YAML validation before commit
- act (local GitHub Actions runner) - Test workflows locally
Install gh CLI:
bash
undefined必需:
- Git 2.0+ - 版本控制
- GitHub CLI (gh) 2.0+ - 密钥管理、PR创建(可选但推荐)
可选:
- yamllint 1.20+ - 提交前YAML验证
- act(本地GitHub Actions运行器)- 本地测试工作流
安装gh CLI:
bash
undefinedmacOS
macOS
brew install gh
brew install gh
Ubuntu
Ubuntu
sudo apt install gh
sudo apt install gh
Verify
验证
gh --version
---gh --version
---Official Documentation
官方文档
- GitHub Actions: https://docs.github.com/en/actions
- Workflow Syntax: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
- CodeQL: https://codeql.github.com/docs/
- Dependabot: https://docs.github.com/en/code-security/dependabot
- Issue Templates: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests
Context7 Library ID: Search for or in Context7 MCP
/websites/github/github/- GitHub Actions:https://docs.github.com/en/actions
- Workflow语法:https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
- CodeQL:https://codeql.github.com/docs/
- Dependabot:https://docs.github.com/en/code-security/dependabot
- Issue模板:https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests
Context7库ID:在Context7 MCP中搜索或
/websites/github/github/Package Versions (Verified 2025-11-06)
包版本(2025-11-06已验证)
GitHub Actions (SHA-pinned in templates):
yaml
actions/checkout: 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
actions/setup-node: 39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
actions/setup-python: 0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
actions/upload-artifact: b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
actions/download-artifact: fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
github/codeql-action/init: ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
github/codeql-action/analyze: ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
codecov/codecov-action: 5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2Verification Command:
bash
undefinedGitHub Actions(模板中通过SHA固定版本):
yaml
actions/checkout: 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
actions/setup-node: 39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
actions/setup-python: 0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
actions/upload-artifact: b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
actions/download-artifact: fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
github/codeql-action/init: ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
github/codeql-action/analyze: ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
codecov/codecov-action: 5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2验证命令:
bash
undefinedCheck latest action versions
检查Action的最新版本
gh api repos/actions/checkout/releases/latest
gh api repos/github/codeql-action/releases/latest
---gh api repos/actions/checkout/releases/latest
gh api repos/github/codeql-action/releases/latest
---Production Example
生产环境示例
This skill is based on production testing across 3 projects:
Project 1: React App
- Template Used: ci-react.yml
- Build Time: 2m 15s (CI), 45s (local)
- Errors: 0 (all 18 known issues prevented)
- Validation: ✅ Type checking, linting, testing, build, CodeQL
Project 2: Cloudflare Worker
- Template Used: ci-cloudflare-workers.yml
- Deploy Time: 1m 30s (automated)
- Errors: 0
- Validation: ✅ Deployed to production, Wrangler deployment successful
Project 3: Python CLI Tool
- Template Used: ci-python.yml (matrix)
- Test Time: 3m 45s (3 Python versions in parallel)
- Errors: 0
- Validation: ✅ Matrix testing on 3.10, 3.11, 3.12
Token Savings: ~70% (26,500 → 7,000 tokens avg)
本技能基于3个项目的生产环境测试:
项目1:React应用
- 使用的模板:ci-react.yml
- 构建时长:2分15秒(CI),45秒(本地)
- 错误:0(所有18类已知问题均被预防)
- 验证:✅ 类型检查、代码扫描、测试、构建、CodeQL
项目2:Cloudflare Worker
- 使用的模板:ci-cloudflare-workers.yml
- 部署时长:1分30秒(自动化)
- 错误:0
- 验证:✅ 成功部署到生产环境、Wrangler部署正常
项目3:Python CLI工具
- 使用的模板:ci-python.yml(矩阵测试)
- 测试时长:3分45秒(3个Python版本并行测试)
- 错误:0
- 验证:✅ 在3.10、3.11、3.12版本上进行矩阵测试
Token节省:约70%(平均从26,500降至7,000)
Troubleshooting
排查问题
Problem: Workflow not triggering
问题:工作流未触发
Symptoms: Pushed code but CI doesn't run
Solutions:
- Check workflow is in (not
.github/workflows/).github/workflow/ - Verify YAML is valid:
yamllint .github/workflows/*.yml - Check trigger matches your branch:
on: push: branches: [main] - Ensure workflow file is committed and pushed
- Check Actions tab in GitHub for error messages
症状:推送代码后CI未运行
解决方案:
- 检查工作流是否在目录中(而非
.github/workflows/).github/workflow/ - 验证YAML是否有效:
yamllint .github/workflows/*.yml - 检查触发器是否匹配你的分支:
on: push: branches: [main] - 确保工作流文件已提交并推送
- 查看GitHub的Actions标签页获取错误信息
Problem: CodeQL failing with "No code found"
问题:CodeQL提示"No code found"
Symptoms: CodeQL workflow completes but finds nothing
Solutions:
- For compiled languages (Java, C++, C#), add build step:
yaml
- name: Build project run: ./mvnw clean install - Verify language is correct in matrix:
yaml
language: ['java-kotlin'] # Not just 'java' - Check CodeQL supports your language (see docs)
症状:CodeQL工作流完成但未找到任何代码
解决方案:
- 对于编译型语言(Java、C++、C#),添加构建步骤:
yaml
- name: Build project run: ./mvnw clean install - 验证矩阵中的语言是否正确:
yaml
language: ['java-kotlin'] # 不只是'java' - 检查CodeQL是否支持你的语言(查看文档)
Problem: Secrets not available in workflow
问题:工作流中密钥不可用
Symptoms: or empty variable
Secret not foundSolutions:
- Verify secret added to repository:
gh secret list - Check syntax uses double braces:
${{ secrets.NAME }} - Secrets are case-sensitive (use exact name)
- For forks, secrets aren't available (security)
症状:或变量为空
Secret not found解决方案:
- 验证密钥已添加到仓库:
gh secret list - 检查语法是否使用双大括号:
${{ secrets.NAME }} - 密钥区分大小写(使用完全匹配的名称)
- 对于复刻仓库,密钥不可用(安全限制)
Problem: Dependabot PRs keep failing
问题:Dependabot PR持续失败
Symptoms: Automated PRs fail CI checks
Solutions:
- Ensure CodeQL triggers on Dependabot PRs:
yaml
on: push: branches: [dependabot/**] - Check branch protection doesn't block bot PRs
- Verify tests pass with updated dependencies locally
- Review Dependabot logs: Settings → Security → Dependabot
症状:自动化PR的CI检查失败
解决方案:
- 确保CodeQL在Dependabot PR上触发:
yaml
on: push: branches: [dependabot/**] - 检查分支保护是否阻止机器人PR
- 验证本地更新依赖后测试是否通过
- 查看Dependabot日志:设置 → 安全 → Dependabot
Problem: Matrix builds all failing
问题:矩阵构建全部失败
Symptoms: All matrix jobs fail with same error
Solutions:
- Check variable reference includes :
matrix.yamlnode-version: ${{ matrix.node-version }} # NOT ${{ node-version }} - Verify matrix values are valid:
yaml
matrix: node-version: [18, 20, 22] # Valid LTS versions - Use to see all failures:
fail-fast: falseyamlstrategy: fail-fast: false
症状:所有矩阵作业因相同错误失败
解决方案:
- 检查变量引用是否包含:
matrix.yamlnode-version: ${{ matrix.node-version }} # 不是${{ node-version }} - 验证矩阵值是否有效:
yaml
matrix: node-version: [18, 20, 22] # 有效的LTS版本 - 使用查看所有失败:
fail-fast: falseyamlstrategy: fail-fast: false
Complete Setup Checklist
完整设置检查清单
Use this checklist to verify your GitHub automation setup:
Workflows:
- Created directory
.github/workflows/ - Copied appropriate CI workflow template
- Updated usernames in workflow files
- Configured secrets (if deploying)
- SHA-pinned all actions (not @latest)
- Explicit runner version (ubuntu-24.04)
- Workflow triggers match branches (main/master)
Issue Templates:
- Created directory
.github/ISSUE_TEMPLATE/ - Copied bug_report.yml
- Copied feature_request.yml
- Updated assignees to your GitHub username
- YAML templates use for critical fields
required: true
PR Template:
- Copied PULL_REQUEST_TEMPLATE.md to
.github/ - Customized checklist for your project needs
Security:
- Copied security-codeql.yml
- Added correct languages to CodeQL matrix
- Set permission
security-events: write - Copied dependabot.yml
- Updated package-ecosystem (npm/pip/etc.)
- Set reviewers in dependabot.yml
Testing:
- Pushed to feature branch first (not main)
- Verified CI runs successfully
- Checked Actions tab for any errors
- Validated YAML syntax locally
- Tested secret access (if applicable)
Documentation:
- Added badge to README.md (optional)
- Documented required secrets in README
- Updated CONTRIBUTING.md (if open source)
Questions? Issues?
- Check for all 18 errors
references/common-errors.md - Verify workflow YAML is valid:
yamllint .github/workflows/*.yml - Check GitHub Actions tab for detailed error messages
- Review official docs: https://docs.github.com/en/actions
- Ensure secrets are configured:
gh secret list
Phase 1 Complete - Core templates and documentation ready
Phase 2-4 Pending - Advanced workflows, scripts, additional guides
Last Updated: 2025-11-06
Version: 1.0.0
Status: Production Ready (Phase 1 Complete)
使用此清单验证你的GitHub自动化设置:
工作流:
- 创建了目录
.github/workflows/ - 复制了合适的CI工作流模板
- 更新了工作流文件中的用户名
- 配置了密钥(若需部署)
- 所有Action均通过SHA固定版本(未使用@latest)
- 指定了明确的运行器版本(ubuntu-24.04)
- 工作流触发器与分支匹配(main/master)
Issue模板:
- 创建了目录
.github/ISSUE_TEMPLATE/ - 复制了bug_report.yml
- 复制了feature_request.yml
- 更新了分配人至你的GitHub用户名
- YAML模板对关键字段使用
required: true
PR模板:
- 复制了PULL_REQUEST_TEMPLATE.md到
.github/ - 根据项目需求自定义了检查清单
安全:
- 复制了security-codeql.yml
- 为CodeQL矩阵添加了正确的语言
- 设置了权限
security-events: write - 复制了dependabot.yml
- 更新了package-ecosystem(npm/pip等)
- 在dependabot.yml中设置了审核人
测试:
- 先推送到功能分支(而非主分支)
- 验证CI运行成功
- 检查Actions标签页是否有错误
- 本地验证YAML语法
- 测试密钥访问(若适用)
文档:
- 为README.md添加了徽章(可选)
- 在README中记录了必需的密钥
- 更新了CONTRIBUTING.md(若开源)
有疑问?遇到问题?
- 查看获取所有18类错误的解决方案
references/common-errors.md - 验证工作流YAML是否有效:
yamllint .github/workflows/*.yml - 查看GitHub Actions标签页获取详细错误信息
- 查阅官方文档:https://docs.github.com/en/actions
- 确保密钥已配置:
gh secret list
第一阶段已完成 - 核心模板和文档已就绪
第二至第四阶段待完成 - 高级工作流、脚本、额外指南
最后更新:2025-11-06
版本:1.0.0
状态:已就绪可用于生产环境(第一阶段已完成)