com um clique
cicd
GitHub Actions 与 GitLab CI 流水线配置、自动测试、构建部署、缓存优化
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
GitHub Actions 与 GitLab CI 流水线配置、自动测试、构建部署、缓存优化
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
生成或审计模块的 SPEC.md。使用场景:用户要求"给 XX 模块写 spec"、"审计所有 spec"、"检查 spec 是否过期"。
Automates SailFish release workflow: fix build/type errors, update CHANGELOG (EN + CN), run npm version with pre/post hooks. Use when the user asks to release, 发版, 发布, bump version, or update changelog.
后端代码修改后,通过 CLI 测试验证功能正确性。使用场景:修改了 electron/services/ 下的代码需要测试、准备提交代码前跑回归、用户要求"跑测试"/"验证一下"。
完成新功能开发或较大修改后,使用本机 Claude CLI 进行代码审查。
使用 ts-morph 静态分析工具查询代码结构(类层次、方法签名、引用、依赖等),替代手动读源码。使用场景:需要了解类的方法/属性、继承链、符号引用、文件结构、依赖关系时。
When committing or staging changes, only include files related to the current task or conversation; do not stage or commit unrelated modifications. Use when the user asks to commit, stage, 提交, or when preparing to run git add/commit.
| name | CI/CD 流水线配置 |
| description | GitHub Actions 与 GitLab CI 流水线配置、自动测试、构建部署、缓存优化 |
| version | 1.0.0 |
文件位置:.github/workflows/<name>.yml
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run build
# 缓存依赖
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm-
# 矩阵测试(多版本)
strategy:
matrix:
node-version: [18, 20, 22]
# 条件执行
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Secret 使用
env:
API_KEY: ${{ secrets.API_KEY }}
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- uses: docker/build-push-action@v5
with:
push: true
tags: registry.cn-hangzhou.aliyuncs.com/myns/app:${{ github.sha }}
文件位置:.gitlab-ci.yml(项目根目录)
stages:
- test
- build
- deploy
variables:
NODE_VERSION: "20"
test:
stage: test
image: node:${NODE_VERSION}
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
script:
- npm ci
- npm test
build:
stage: build
image: node:${NODE_VERSION}
script:
- npm ci
- npm run build
artifacts:
paths:
- dist/
expire_in: 1 week
deploy:
stage: deploy
image: alpine:latest
only:
- main
script:
- apk add --no-cache rsync openssh-client
- rsync -avz -e "ssh -o StrictHostKeyChecking=no" dist/ $DEPLOY_USER@$DEPLOY_HOST:/var/www/app/
# 缓存 Docker 层
build-image:
stage: build
image: docker:latest
services:
- docker:dind
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
# 手动部署(需点击确认)
deploy-prod:
stage: deploy
when: manual
environment:
name: production
# 规则控制
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "main"'