ci-cd-pipelines

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

CI/CD Pipelines

CI/CD 流水线

Description

描述

CI/CD Pipelines defines production-grade continuous integration and deployment workflows using GitHub Actions with wrangler deploy, link validation, HTML validation, and automated quality gates. This skill encodes the actual CI/CD patterns used by googleadsagent.ai™ to deploy Workers, validate 18,000+ pages of generated content, and maintain zero-downtime production releases.
A CI pipeline is only as valuable as its gates. This skill goes beyond "run tests and deploy" to include HTML validation (no broken markup in generated pages), internal link checking (no dead links across the city × service matrix), structured data validation (JSON-LD schema compliance), and Lighthouse performance audits. Every merge to main triggers a cascade of validation steps that catch regressions before they reach production.
The deployment pipeline implements progressive rollout: deploy to a staging environment first, run the full validation suite against staging, promote to production only on green, and maintain instant rollback capability via wrangler rollback. Preview deployments for pull requests give reviewers a live URL to test changes before approval.
CI/CD 流水线使用 GitHub Actions 配合 wrangler deploy、链接验证、HTML 验证和自动化质量门禁,定义生产级持续集成与部署工作流。该 Skill 编码了 googleadsagent.ai™ 实际使用的 CI/CD 模式,用于部署 Workers、验证生成的 18,000+ 个页面内容,并维持零停机生产发布。
CI 流水线的价值取决于其门禁。该 Skill 的功能不止于“运行测试并部署”,还涵盖 HTML 验证(确保生成的页面没有损坏的标记)、内部链接检查(确保城市 × 服务矩阵中不存在死链)、结构化数据验证(JSON-LD schema 合规性)以及 Lighthouse 性能审计。每次合并到 main 都会触发一系列级联验证步骤,在问题进入生产环境之前捕获回归。
部署流水线采用渐进式发布策略:先部署到 staging 环境,再针对 staging 运行完整的验证套件,仅在所有检查全绿时提升至生产环境,并通过 wrangler rollback 保持即时回滚能力。Pull Request 的预览部署会为审查者提供一个可供测试变更的实时 URL。

Use When

使用场景

  • Setting up CI/CD for Cloudflare Workers or Pages projects
  • Adding HTML validation or link checking to a pipeline
  • Implementing progressive deployment with staging and production
  • Automating quality gates for content-heavy sites
  • Configuring preview deployments for pull requests
  • Building rollback capability into deployment workflows
  • 为 Cloudflare Workers 或 Pages 项目设置 CI/CD
  • 在流水线中添加 HTML 验证或链接检查
  • 实现包含 staging 和生产环境的渐进式部署
  • 为内容密集型网站自动化质量门禁
  • 为 Pull Request 配置预览部署
  • 在部署工作流中构建回滚能力

How It Works

工作原理

mermaid
graph TD
    A[Push to Branch] --> B[GitHub Actions Trigger]
    B --> C[Install Dependencies]
    C --> D[Run Unit Tests]
    D --> E[Run Type Checking]
    E --> F{Branch?}
    F -->|PR| G[Deploy to Preview]
    F -->|main| H[Deploy to Staging]
    G --> I[Run Link Checker on Preview]
    H --> J[Run Full Validation Suite]
    J --> K[HTML Validation]
    J --> L[Link Checking]
    J --> M[JSON-LD Validation]
    J --> N[Lighthouse Audit]
    K --> O{All Green?}
    L --> O
    M --> O
    N --> O
    O -->|Yes| P[Promote to Production]
    O -->|No| Q[Block + Notify]
    I --> R[Comment PR with Preview URL]
The pipeline fans out for validation (HTML, links, JSON-LD, Lighthouse run in parallel) and gates on the aggregate result. Production promotion only occurs when all gates pass.
mermaid
graph TD
    A[Push to Branch] --> B[GitHub Actions Trigger]
    B --> C[Install Dependencies]
    C --> D[Run Unit Tests]
    D --> E[Run Type Checking]
    E --> F{Branch?}
    F -->|PR| G[Deploy to Preview]
    F -->|main| H[Deploy to Staging]
    G --> I[Run Link Checker on Preview]
    H --> J[Run Full Validation Suite]
    J --> K[HTML Validation]
    J --> L[Link Checking]
    J --> M[JSON-LD Validation]
    J --> N[Lighthouse Audit]
    K --> O{All Green?}
    L --> O
    M --> O
    N --> O
    O -->|Yes| P[Promote to Production]
    O -->|No| Q[Block + Notify]
    I --> R[Comment PR with Preview URL]
流水线会并行展开各项验证(HTML、链接、JSON-LD 和 Lighthouse 并行运行),并以汇总结果作为门禁。只有当所有门禁通过后,才会提升到生产环境。

Implementation

实现

yaml
name: CI/CD Pipeline
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: "20" }
      - run: npm ci
      - run: npx tsc --noEmit
      - run: npm test

  deploy-staging:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: "20" }
      - run: npm ci
      - run: npx wrangler deploy --env staging
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}

  validate:
    needs: deploy-staging
    runs-on: ubuntu-latest
    strategy:
      matrix:
        check: [html, links, jsonld, lighthouse]
    steps:
      - uses: actions/checkout@v4
      - name: HTML Validation
        if: matrix.check == 'html'
        run: |
          npx html-validate "https://staging.googleadsagent.ai" \
            --config .htmlvalidate.json
      - name: Link Checking
        if: matrix.check == 'links'
        run: |
          npx linkinator https://staging.googleadsagent.ai \
            --recurse --timeout 30000 \
            --skip "^https://(?!staging\.googleadsagent\.ai)"
      - name: JSON-LD Validation
        if: matrix.check == 'jsonld'
        run: node scripts/validate-jsonld.js --base-url=https://staging.googleadsagent.ai
      - name: Lighthouse Audit
        if: matrix.check == 'lighthouse'
        run: |
          npx lhci autorun --config=lighthouserc.json \
            --collect.url=https://staging.googleadsagent.ai

  deploy-production:
    needs: validate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: "20" }
      - run: npm ci
      - run: npx wrangler deploy --env production
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
yaml
name: CI/CD Pipeline
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: "20" }
      - run: npm ci
      - run: npx tsc --noEmit
      - run: npm test

  deploy-staging:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: "20" }
      - run: npm ci
      - run: npx wrangler deploy --env staging
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}

  validate:
    needs: deploy-staging
    runs-on: ubuntu-latest
    strategy:
      matrix:
        check: [html, links, jsonld, lighthouse]
    steps:
      - uses: actions/checkout@v4
      - name: HTML Validation
        if: matrix.check == 'html'
        run: |
          npx html-validate "https://staging.googleadsagent.ai" \
            --config .htmlvalidate.json
      - name: Link Checking
        if: matrix.check == 'links'
        run: |
          npx linkinator https://staging.googleadsagent.ai \
            --recurse --timeout 30000 \
            --skip "^https://(?!staging\.googleadsagent\.ai)"
      - name: JSON-LD Validation
        if: matrix.check == 'jsonld'
        run: node scripts/validate-jsonld.js --base-url=https://staging.googleadsagent.ai
      - name: Lighthouse Audit
        if: matrix.check == 'lighthouse'
        run: |
          npx lhci autorun --config=lighthouserc.json \
            --collect.url=https://staging.googleadsagent.ai

  deploy-production:
    needs: validate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: "20" }
      - run: npm ci
      - run: npx wrangler deploy --env production
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}

Best Practices

最佳实践

  • Run validation checks in parallel using matrix strategy to minimize pipeline duration
  • Store the previous deployment version for instant rollback via
    wrangler rollback
  • Cache
    node_modules
    and build artifacts between jobs to reduce install time
  • Set Lighthouse performance budgets and fail the pipeline on regressions
  • Use OIDC tokens instead of long-lived API tokens for Cloudflare authentication
  • Monitor pipeline duration as a metric—slow pipelines reduce deployment frequency
  • 使用 matrix 策略并行运行验证检查,以缩短流水线耗时
  • 通过
    wrangler rollback
    保存上一个部署版本,以实现即时回滚
  • 在作业之间缓存
    node_modules
    和构建产物,以减少安装时间
  • 设置 Lighthouse 性能预算,并在出现回归时让流水线失败
  • 使用 OIDC 令牌代替长期有效的 API 令牌进行 Cloudflare 身份验证
  • 将流水线耗时作为监控指标——缓慢的流水线会降低部署频率

Platform Compatibility

平台兼容性

PlatformSupportNotes
CursorFullGitHub Actions authoring
VS CodeFullGitHub Actions extension
WindsurfFullCI/CD workflow support
Claude CodeFullYAML generation + validation
ClineFullPipeline configuration
aiderFullYAML file editing
平台支持情况备注
Cursor完全支持GitHub Actions 编写
VS Code完全支持GitHub Actions 扩展
Windsurf完全支持CI/CD 工作流支持
Claude Code完全支持YAML 生成与验证
Cline完全支持流水线配置
aider完全支持YAML 文件编辑

Related Skills

相关 Skills

  • Cloudflare Workers
  • Edge Rendering
  • Observability
  • Agent Security Scanning
  • Cloudflare Workers
  • Edge Rendering
  • Observability
  • Agent Security Scanning

Keywords

关键词

ci-cd
github-actions
wrangler-deploy
html-validation
link-checking
lighthouse
progressive-deployment
quality-gates

© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License
ci-cd
github-actions
wrangler-deploy
html-validation
link-checking
lighthouse
progressive-deployment
quality-gates

© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License