SuperAPI AI 工具集

gh-actions

部署与运维

查看项目

更新于 10-15 17:29

技能介绍

用途:在创建 GitHub Actions 工作流、发布自动化、校验和、签名或 CI/CD 时使用,提供经生产验证的模式与 2025-2026 最佳实践。

主要能力:按需求给出工作流模板,如 ci.yml(推送/PR 的 CI)、release.yml(打标签发布)、fuzz.yml(夜间模糊测试/基准)、dependabot.yml(依赖更新)。核心模式包括 on 触发(push 到 main、pull_request、workflow_dispatch)、concurrency 并发控制(发布时 cancel-in-progress 设为 false)、最小权限 permissions(默认 contents: read)、显式 timeout-minutes(避免默认 6 小时)。

语言与缓存:Rust 用 dtolnay/rust-toolchain@stable 与 Swatinem/rust-cache@v2;Go 用 actions/setup-go@v6(内置缓存);TypeScript 用 oven-sh/setup-bun@v2;Python 用 astral-sh/setup-uv@v7;Bash 无专用 setup。Node/Bun 用 actions/cache@v4 缓存 node_modules,缓存键需包含架构,如 key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock') }}。

跨平台矩阵:使用 include 列出 ubuntu-latest、ubuntu-24.04-arm、macos-14、macos-15-intel、windows-latest 及对应 target,fail-fast: false;原生 ARM runner 比 QEMU 模拟快约 10 倍。

发布清单:跨平台构建矩阵、生成 sha256sum 校验和、签名(minisign/cosign)、用 softprops/action-gh-release@v2 创建 Release、通知包管理器(Homebrew/Scoop)、用 syft 生成 SBOM、附加 SLSA 溯源。

安全实践:第三方 action 固定到 SHA、OIDC 认证(id-token: write)、无密钥签名(sigstore/cosign-installer@v3)、SLSA Level 3(actions/attest-build-provenance@v2)。反模式:勿用 @main、勿用默认 6 小时超时、勿用 QEMU 构建 ARM、勿在工作流中存密钥、勿跳过并发控制。

验证:actionlint .github/workflows/*.yml;gh workflow list && gh run list --workflow=ci.yml。

限制:资料未提供具体收费、价格、平台支持范围与效果数据,暂未提供。