GitHub Actions 自动化交付助手
简介
GitHub Actions 纯文档指南,提供从测试到部署的完整工作流模板,帮助开发团队快速构建可靠的自动化交付管道。
原始描述
Create, debug, and manage CI/CD pipelines with GitHub Actions. Use when the user needs to set up automated testing, deployment, releases, or workflows. Covers workflow syntax, common patterns, secrets management, caching, matrix builds, and troubleshooting.
通过你的 Agent 添加
安装目录:cicd-pipeline/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
本 Skill 是一套完整的 GitHub Actions CI/CD 配置参考手册,定位为"即查即用的工作流模板库"。内容涵盖:
- 多语言快速启动模板:Node.js、Python、Go、Rust 项目的标准化 CI 配置,包含依赖缓存、测试、Lint 等完整步骤
- 进阶模式:矩阵构建(跨版本/OS 测试)、条件作业、产物缓存、定时触发、并发控制等复杂场景
- 部署场景:Docker 镜像构建推送、npm 发布、多环境(staging/production)自动部署、GitHub Release 自动化
- 密钥管理:通过
ghCLI 设置仓库/环境级密钥,以及在 workflow 中安全引用的完整指南 - 调试排障:SSH 远程调试、日志查看、失败重跑、本地 YAML 校验等实用技巧
显著优点
- 覆盖面广:从单项目 CI 到 Monorepo 增量测试,从开源发布到企业级多环境部署,场景齐全
- 即拷即用:所有代码块均为可直接粘贴的完整 YAML,降低上手门槛
- 安全导向:明确提及 SHA 固定版本、最小权限
permissions、密钥管理等供应链安全实践
- 生态原生:深度整合
gh CLI,支持命令行全流程管理,契合开发者现有工具链
潜在局限
- 平台锁定:完全基于 GitHub Actions,不适用于 GitLab CI、Jenkins、CircleCI 等其他平台
- 无动态生成:纯静态文档,无法根据用户仓库结构自动生成配置文件
- 版本维护依赖:Action 版本号(如
v4)需人工跟进更新,文档滞后可能导致使用旧版本
- 复杂场景简化:大型企业级发布流程(如金丝雀部署、回滚策略)仅提及概念,无完整实现
适合人群
- 个人开发者/小团队快速搭建项目 CI/CD 基础设施
- 开源项目维护者需要标准化 release 流程
- 对 GitHub Actions 语法不熟悉、需要现成模板的用户
- 希望优化现有 workflow(缓存策略、并发控制、Monorepo 优化)的进阶用户
常规风险
- 密钥泄露误操作:新手可能误将
secrets.XXX 打印到日志或硬编码在 workflow 中
- 权限过度授予:复制模板时未根据实际需求裁剪
permissions,导致 token 权限过大
- 第三方 Action 风险:文档中引用的社区 Action(如
softprops/action-gh-release)需自行评估维护状态
- 缓存中毒:不当的缓存 key 策略可能导致旧依赖被反复使用,或恶意依赖被缓存传播
permissions、密钥管理等供应链安全实践gh CLI,支持命令行全流程管理,契合开发者现有工具链- 平台锁定:完全基于 GitHub Actions,不适用于 GitLab CI、Jenkins、CircleCI 等其他平台
- 无动态生成:纯静态文档,无法根据用户仓库结构自动生成配置文件
- 版本维护依赖:Action 版本号(如
v4)需人工跟进更新,文档滞后可能导致使用旧版本 - 复杂场景简化:大型企业级发布流程(如金丝雀部署、回滚策略)仅提及概念,无完整实现
适合人群
- 个人开发者/小团队快速搭建项目 CI/CD 基础设施
- 开源项目维护者需要标准化 release 流程
- 对 GitHub Actions 语法不熟悉、需要现成模板的用户
- 希望优化现有 workflow(缓存策略、并发控制、Monorepo 优化)的进阶用户
常规风险
- 密钥泄露误操作:新手可能误将
secrets.XXX 打印到日志或硬编码在 workflow 中
- 权限过度授予:复制模板时未根据实际需求裁剪
permissions,导致 token 权限过大
- 第三方 Action 风险:文档中引用的社区 Action(如
softprops/action-gh-release)需自行评估维护状态
- 缓存中毒:不当的缓存 key 策略可能导致旧依赖被反复使用,或恶意依赖被缓存传播
- 密钥泄露误操作:新手可能误将
secrets.XXX打印到日志或硬编码在 workflow 中 - 权限过度授予:复制模板时未根据实际需求裁剪
permissions,导致 token 权限过大 - 第三方 Action 风险:文档中引用的社区 Action(如
softprops/action-gh-release)需自行评估维护状态 - 缓存中毒:不当的缓存 key 策略可能导致旧依赖被反复使用,或恶意依赖被缓存传播
技能正文
name: cicd-pipeline
description: >-
Generate and optimize CI/CD pipelines for GitLab CI and CircleCI. Use when a
user asks to set up GitLab CI, create a CircleCI pipeline, build a CI pipeline
for GitLab, automate deployments with CircleCI, add test automation to GitLab,
or configure continuous integration on non-GitHub platforms. For GitHub Actions
pipelines, use the github-actions skill instead.
license: Apache-2.0
compatibility: "Any project with Git version control"
metadata:
author: terminal-skills
version: "1.2.0"
category: devops
tags: "cicd, gitlab-ci, circleci, pipeline, deployment"
CI/CD Pipeline (GitLab CI & CircleCI)
Overview
Overview
Generate production-ready CI/CD pipeline configurations for automated testing, building, and deploying applications on GitLab CI and CircleCI. This skill creates well-structured workflows with proper caching, matrix testing, environment separation, and deployment strategies. For GitHub Actions pipelines, use the github-actions skill.
Instructions
When a user asks to create or improve a CI/CD pipeline, follow these steps:
Step 1: Analyze the project
Detect the project type and requirements:
# Determine language and framework
ls package.json pyproject.toml Gemfile go.mod Cargo.toml pom.xml build.gradle 2>/dev/null
# Check for existing CI config
ls .gitlab-ci.yml .circleci/config.yml 2>/dev/null
# Detect test commands
cat package.json | grep -A5 '"scripts"' 2>/dev/null
cat Makefile 2>/dev/null | grep -E "^test|^lint|^build"
Identify:
- Language/runtime: Node.js, Python, Go, Rust, Java
- Package manager: npm, pnpm, yarn, pip, poetry
- Test framework: Jest, Pytest, Go test, etc.
- Build output: Docker image, static site, binary, package
- Deploy target: AWS, Docker registry, npm registry, SSH server
Step 2: Choose the CI/CD platform
Default to GitLab CI if the repo is on GitLab. Use CircleCI if specified or if the project already has a .circleci/ directory.
Step 3: Generate the pipeline configuration
GitLab CI: Node.js example:
# .gitlab-ci.yml
stages:
- lint
- test
- build
- deploy
variables:
NODE_VERSION: "22"
npm_config_cache: "$CI_PROJECT_DIR/.npm"
.node-job:
image: node:${NODE_VERSION}
cache:
key:
files:
- package-lock.json
paths:
- .npm/
before_script:
- npm ci
lint:
extends: .node-job
stage: lint
script:
- npm run lint
test:
extends: .node-job
stage: test
script:
- npm test -- --coverage
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
build:
extends: .node-job
stage: build
script:
- npm run build
artifacts:
paths:
- dist/
expire_in: 1 week
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
Use rules: for conditions. only/except are deprecated GitLab keywords. Without a workflow:rules block, a push with an open merge request can start two pipelines (branch and MR); add workflow: rules if you see duplicates. The Cobertura file is produced by Jest's coverageReporters: ['text', 'cobertura'].
GitLab CI: Docker build and deploy:
build-image:
stage: build
image: docker:29-cli
services:
- docker:29-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
deploy:
stage: deploy
image: alpine:3.22
before_script:
- apk add --no-cache openssh-client
- eval "$(ssh-agent -s)"
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- mkdir -p ~/.ssh && echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
script:
- ssh "$DEPLOY_USER@$DEPLOY_HOST" "docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA && IMAGE_TAG=$CI_COMMIT_SHA docker compose up -d"
environment: production
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
SSH_KNOWN_HOSTS holds the output of ssh-keyscan taken once and checked by a human; do not disable host key checking with StrictHostKeyChecking=no. The server must have logged in to the registry too, or use a deploy token.
CircleCI: Node.js example:
# .circleci/config.yml
version: 2.1
orbs:
node: circleci/node@7
jobs:
lint-and-test:
docker:
- image: cimg/node:22.23
steps:
- checkout
- node/install-packages
- run: npm run lint
- run: npm test -- --coverage --reporters=default --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT_DIR: test-results
- store_test_results:
path: test-results
- store_artifacts:
path: coverage
build:
docker:
- image: cimg/node:22.23
steps:
- checkout
- node/install-packages
- run: npm run build
- persist_to_workspace:
root: .
paths: [dist]
deploy:
docker:
- image: cimg/node:22.23
steps:
- checkout
- attach_workspace:
at: .
- run: npx vercel deploy --prod --prebuilt --token "$VERCEL_TOKEN"
workflows:
build-and-deploy:
jobs:
- lint-and-test
- build:
requires: [lint-and-test]
- deploy:
requires: [build]
filters:
branches:
only: main
jest-junit must be a dev dependency for the test report step. cimg/node tags are major.minor (for example 22.23); the circleci/node orb's install-packages caches dependencies by lockfile automatically. Node 20 reached end of life in April 2026, so new pipelines should start on 22 or 24.
CircleCI monorepo path filtering needs dynamic configuration: set setup: true in .circleci/config.yml, use the circleci/path-filtering@3 orb to map changed paths to pipeline parameters (mapping: "packages/api/.* run-api true"), and put the per-package workflows in .circleci/continue_config.yml with when: << pipeline.parameters.run-api >>. Dynamic config must be enabled in the project settings.
Examples
Example 1: GitLab CI for a Django API with Docker deployment
User request: "Create a GitLab CI pipeline for my Django app with Docker deployment"
Actions taken:
- Detected: Django 5.2, Poetry, Pytest, PostgreSQL dependency
- Created
.gitlab-ci.ymlwith lint, test (with Postgres service), build, deploy stages - Added Postgres service container for integration tests
- Configured Docker image build and push to GitLab Container Registry
Result:
Created: .gitlab-ci.yml
Stages: lint -> test -> build -> deploy
- lint: ruff + mypy type checking
- test: pytest with PostgreSQL 16 service container
- build: Docker image build, pushed to $CI_REGISTRY_IMAGE
- deploy: SSH deploy to production (manual trigger)
Required variables: DEPLOY_HOST, DEPLOY_USER, SSH_PRIVATE_KEY
Example 2: CircleCI for a Node.js monorepo
User request: "Set up CircleCI for my monorepo with separate test jobs per package"
Actions taken:
- Detected: pnpm workspace with 3 packages (api, web, shared)
- Created
.circleci/config.ymlwith parallel test jobs per package - Used path filtering to only run jobs for changed packages
- Added build and deploy workflow for the web package
Result:
Created: .circleci/config.yml
Jobs: test-api, test-web, test-shared, build-web, deploy-web
- Uses path filtering: only tests changed packages
- Shared dependency caching across jobs
- Deploy to Vercel on main branch only
Required env vars: VERCEL_TOKEN
Estimated run time: ~4 minutes (parallel jobs)
Guidelines
- Enable dependency caching to speed up runs. GitLab uses
cache: blocks; CircleCI uses orbs or save_cache/restore_cache.
- Use service containers for database tests (Postgres, Redis, etc.) rather than installing them in the job.
- Separate CI (runs on every push/MR) from CD (runs only on main/tags).
- Store secrets in CI/CD variables, never in pipeline files. In GitLab, mark them Masked and Protected; protected variables are only exposed to protected branches and tags.
- Pin image tags to a major version (
node:22, docker:29-cli), not latest.
- Use
rules: in GitLab CI (not the deprecated only/except) or filters in CircleCI to control when jobs run.
- For monorepos, use path-based triggers to only run relevant pipelines.
- GitLab CI supports
extends, include and YAML anchors for DRY configs — use them for shared job configurations.
- CircleCI orbs encapsulate common patterns (Node, Python, Docker) — prefer orbs over manual setup.
- Add
when: manual in GitLab CI or approval jobs in CircleCI for production deploys to prevent accidental releases.
cache: blocks; CircleCI uses orbs or save_cache/restore_cache.node:22, docker:29-cli), not latest.rules: in GitLab CI (not the deprecated only/except) or filters in CircleCI to control when jobs run.extends, include and YAML anchors for DRY configs — use them for shared job configurations.when: manual in GitLab CI or approval jobs in CircleCI for production deploys to prevent accidental releases.