Community程式設計與開發github.com

bentoms-dev/github-actions-cicd-engineer

快速建立安全且易於維護的 GitHub Actions CI/CD 管線。用於建立或修復工作流程、加速緩慢的 CI、加入快取、矩陣或部署、管理 Secrets 與環境、強化工作流程以防供應鏈攻擊,或設定發行版與預覽部署。

github-actions-cicd-engineer 是什麼?

這個技能專注於設計與實作 GitHub Actions CI/CD 管線,目標是讓管線速度快到開發者無需等待、嚴謹到能捕捉問題,並鎖定安全防護以避免被用於危害儲存庫。技能涵蓋從觸發條件、平行作業、快取策略、矩陣測試、安全強化(如最低權限權限、固定第三方 Action SHA、避免腳本注入、使用 OIDC 與環境保護規則),到部署、發行版管理與可維護性等面向。支援的平台為 GitHub Actions,並且強烈建議將重複設定萃取為複合 Action 或可重複使用的工作流程。此技能也整合了諸如 actionlint 驗證、Dependabot 自動更新相依套件、以及基於 Conventional Commits 的自動版本與變更紀錄等最佳實務。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/bentoms-dev/skills/tree/HEAD/skills/engineering/github-actions-cicd-engineer

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

GitHub Actions CI/CD 工程師

您建立的管線要快到開發者不必等待,嚴格到能捕捉問題,並且鎖定安全防護,使其無法被用來危害儲存庫。

管線結構

  • 在 pull request 上:安裝、lint、型別檢查、單元與整合測試、建置。將獨立的作業平行執行。
  • 在合併到 main 分支時:執行相同的檢查,然後建置一次成品,並將同一個成品部署到 staging,再到 production。
  • 快速失敗:先執行最便宜的檢查,或與昂貴的檢查平行執行。
  • 使用 concurrency 取消同一個分支上已被取代的執行:
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
  • 使用路徑篩選器,讓僅變動文件的提交跳過耗時作業,但保持必要的狀態檢查可滿足(使用一個輕量級的永遠執行作業或條件式步驟)。

速度

  • 使用 setup action 內建的快取來快取相依套件(actions/setup-node 搭配 cache: npm、setup-python 搭配 cache: pip),並以 lockfile 作為鍵值來快取建置輸出(Next.js .next/cache、Turborepo、Gradle)。
  • 使用 npm ci(或等效的 frozen-lockfile 安裝)來進行可重現的安裝。
  • 將慢速的測試套件分散到矩陣中。端對端測試僅針對已建置的應用程式執行。
  • 在矩陣中,當您需要每個結果時使用 fail-fast: false,當您只需要知道失敗時使用 true。
  • 在每個作業上設定 timeout-minutes,以免卡住的執行浪費時間。

安全強化

  • 在每個工作流程的頂端設定最低權限權限,並只在需要時才放寬個別作業的權限:
permissions:
  contents: read
  • 將第三方 Action 固定到完整的提交 SHA,並在註解中標明版本(uses: owner/action@<sha> # v4.2.0)。讓 Dependabot 或 Renovate 更新它們。
  • 絕不使用 pull_request_target 或 workflow_run 來檢出並執行含有 secrets 的不受信任 PR 程式碼。Fork 的 PR 不得取得 secrets 或寫入權杖。
  • 防止腳本注入:絕不將不受信任的上下文(github.event.pull_request.title、issue 內文、分支名稱)直接插值到 run: 中。改透過 env: 傳遞並對變數加上引號。
  • 使用 OIDC(id-token: write)來取得短期的雲端憑證,而非儲存為 secrets 的長期金鑰。
  • 將部署 secrets 放在環境中,並設定必要的審查者與分支保護,而不是放在儲存庫層級的 secrets 中。
  • 不要輸出 secrets;小心使用 set -x 與除錯記錄。
  • 啟用 npm 與 GitHub Actions 的 Dependabot,並執行相依性稽核或程式碼掃描作業。

部署

  • 透過環境(staging、production)進行部署,並設定保護規則與 URL。
  • 讓部署具有冪等性且可回退(重新部署先前的成品或標籤)。
  • 將資料庫遷移作為一個明確、有序的步驟執行,該步驟需與目前執行的版本向後相容。
  • 在平台支援的情況下,為每個 PR 使用預覽部署,並在 PR 上留言 URL。
  • 針對已部署的 URL 執行煙霧測試,若測試失敗則讓作業失敗。

可維護性

  • 將重複的設定萃取為複合 Action 或可重複使用的工作流程(workflow_call)。
  • 明確命名作業與步驟;必要的狀態檢查依賴於作業名稱,因此重新命名時要小心。
  • 當可重現性比自動升級更重要時,固定執行器映像檔(ubuntu-24.04)。
  • 使用 actionlint 驗證工作流程檔案。

發行版

  • 從 Conventional Commits 自動化版本編號與變更紀錄(例如 release-please 或 changesets)。
  • 在支援的平台上,使用 OIDC 發布帶有來源證明的套件(npm publish --provenance)。

輸出

描述管線(觸發條件、作業、作業間的相依性)、預期的執行時間(改善前與改善後)、授予的權限及其原因、所需的 secrets 與環境,以及在儲存庫設定中需要手動進行的設定(分支保護、必要的狀態檢查、環境)。


深入閱讀: Security Audit Pro 與 Observability & Incident Response 是進階技能包,包含相關技能、生產用範本、腳本與評估提示。

Individual skills in this repo

This repo contains 5 individual skills — each has its own dedicated page.

bentoms-dev/ai-feature-engineer

Build reliable, safe and affordable LLM-powered features in real products. Use when adding chat, summarisation, extraction, classification, RAG search, tool calling or agents to an app, when writing prompts or evals, choosing models, controlling cost and latency, or defending against prompt injection.

bentoms-dev/docs-readme-writer

Write developer documentation people actually read and trust. Use when creating or improving a README, getting-started guide, API reference, architecture decision record (ADR), runbook, onboarding guide, changelog or contributing guide, or when docs are outdated, confusing or missing.

bentoms-dev/postgres-migrations-engineer

Design PostgreSQL schemas, write zero-downtime migrations and fix slow queries. Use when adding tables, columns, indexes or constraints, changing data on a live database, reviewing a migration for locking risks, reading EXPLAIN ANALYZE output, or working with Prisma, Drizzle, Knex, TypeORM, Rails or Django migrations.

bentoms-dev/shopify-theme-architect

Build, refactor and review Shopify Online Store 2.0 themes. Use when creating or editing Liquid sections, blocks, snippets, templates, theme settings, locales, or theme CSS/JS, and when reviewing a theme for performance, accessibility or merchant editability.

bentoms-dev/test-engineer

Write tests that catch real bugs and survive refactors. Use when adding tests to new or existing code, choosing between unit, integration and end-to-end tests, fixing flaky tests, setting up Vitest, Jest or Playwright, or reviewing a test suite for gaps and brittleness.

相關技能