Communitygithub.com

Nuvraxis/nuvraxis-plugins

Nuvraxis Next.js 應用的 GitHub Actions 慣例,提供三個精簡工作流程:pr.yaml(PR 檢查但不發布)、main.yaml(建置多架構映像並推送至 GHCR)、release.yaml(無重建、透過 imagetools 重新標記、推送 Helm Chart 並建立 GitHub Release)。

nuvraxis-plugins 是什麼?

這個技能定義了 Nuvraxis 生態系統中 Next.js 應用的標準 GitHub Actions 工作流程。它提供三個嚴格的工作流程:pr.yaml 在每個 PR 上執行檢查(Biome、stylelint、turbo --affected、Docker 健康檢查、Helm lint 和 kubeconform)但不發布任何內容;main.yaml 在合併到 main 時建置一個雙架構映像,並以 sha-SHORTSHA 和 main 標記將其推送到 GHCR,並附帶完整來源和 SBOM;release.yaml 在推送 vX.Y.Z 標籤時,在驗證提交位於 main 上之後,透過 `docker buildx imagetools create` 重新標記現有映像,然後打包並推送 Helm Chart 到 OCI 註冊表,並建立包含 chart、摘要和 SBOM 的 GitHub Release。該技能強調了關鍵的安全性和可靠性規則:使用最小權限、僅使用 GITHUB_TOKEN、固定主要動作版本、正確的相依性安裝順序(pnpm/action-setup 在 actions/setup-node 之前)、按工作流程和參考進行並發控制、永遠不接受不受信任的輸入,以及所有工作設定逾時。此技能主要在編輯 `.github/workflows/*` 檔案時使用,也適用於新增 CI 步驟或偵錯執行失敗或發佈問題。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Nuvraxis/nuvraxis-plugins/tree/HEAD/plugins/nuvraxis-frontend/skills/github-actions

在你喜歡的 AI 中提問

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

說明文件

GitHub Actions

每個應用程式三個工作流程,每個類型各一個任務。範本的 .github/workflows/{pr,main,release}.yaml 是真相來源;它們的註解版本位於 references/workflows.md。

pull request ──► pr.yaml       僅檢查,不發布任何內容
合併至 main ──► main.yaml     映像僅建置一次 → ghcr.io/nuvraxis/<app>:sha-<short>, :main
tag vX.Y.Z ────► release.yaml 同一映像重新標記為 :vX.Y.Z, :latest · chart X.Y.Z → OCI · GitHub Release

每個工作流程的規則

  1. 在頂層設定 permissions: contents: read;僅在需要的任務中放寬權限。 需要推送到 GHCR 的任務設定 packages: write,僅建立 Release 的任務設定 contents: write。不需要 id-token: write 或 attestations: write:來源和 SBOM 來自 BuildKit,而非 actions/attest*(後者在私有儲存庫中需要 GitHub Enterprise)。

  2. 僅使用 GITHUB_TOKEN。 GHCR 登入使用 ${{ github.actor }} / ${{ secrets.GITHUB_TOKEN }};gh 使用 GH_TOKEN: ${{ github.token }}。CI 中不使用個人存取權杖。(從叢集拉取私有套件是另一組憑證;請參閱 helm-nextjs。)

  3. 固定動作的主要版本(@v7)並保持 SHA 表為最新。 範本為了可讀性而使用主要版本標籤。如果組織要求固定 SHA,則將每個 @vN 替換為 references/action-pins.md 中的 SHA,並保留 # vN.M.P 註解。目前的主要版本:checkout v7, setup-node v7, pnpm/action-setup v6, setup-qemu v4, setup-buildx v4, login v4, metadata v6, build-push v7, azure/setup-helm v5。

  4. 工具鏈:pnpm/action-setup 在 actions/setup-node 之前。 action-setup 從 packageManager 讀取 pnpm 版本;setup-node 讀取 .node-version 並快取 pnpm store(cache: pnpm 需要先將 pnpm 加入 PATH)。然後執行 pnpm install --frozen-lockfile。絕對不要使用 npm ci。

  5. 按工作流程和參考進行 concurrency 控制;僅在 PR 上取消進行中的執行。 對 PR 的新推送會取消舊的執行。在 main 和標籤上,執行總是會完成:release.yaml 需要該確切提交的映像。

  6. 永遠不要輸出 secrets 或將不受信任的輸入內插到 run: 中。 透過 env: 傳遞值並引用它們("${APP}")。${{ github.event.pull_request.title }} 等內容永遠不會進入腳本內部。當任務不推送到 git 時,在 checkout 上設定 persist-credentials: false。

  7. 每個任務都設定 timeout-minutes。 否則掛起的 Docker 建置會消耗六小時。

  8. 名稱使用小寫。 GHCR 拒絕大寫的儲存庫。IMAGE: ghcr.io/nuvraxis/<app> 在 env 中寫為小寫;scaffold 會將應用程式名稱轉為小寫。

pr.yaml

  1. on: pull_request 搭配 types: [opened, synchronize, reopened, ready_for_review] 且沒有 branches 過濾器,這樣針對功能分支的堆疊 PR 也會被檢查。每個任務都有 if: ${{ !github.event.pull_request.draft }};標記為 ready 會觸發執行。

  2. 四個並行任務: quality(biome ci --reporter=github、stylelint、turbo run typecheck test --affected、pnpm audit --audit-level high)、build(turbo run build --affected)、docker(建置一個平台,使用 load: true、以唯讀模式執行並移除功能、curl /api/health)、helm(對兩個 values 檔案執行 helm lint --strict 和 kubeconform)。--affected 需要 fetch-depth: 0。

  3. PR 不會推送任何內容。 push: false,唯讀快取(僅 cache-from),不登入註冊表。

main.yaml

  1. on: push: branches: [main] 僅建置一次映像,適用於兩種架構,並推送它。 docker/metadata-action 的標籤:type=sha,format=short,prefix=sha- 和 type=raw,value=main、flavor: latest=false。latest 屬於發佈版本。

  2. provenance: mode=max、sbom: true、cache-from/to: type=gha,scope=<app>,mode=max。 來源和 SBOM 附加到映像索引上;release.yaml 在重新標記時會一併攜帶它們。NEXT_DEPLOYMENT_ID=${{ github.sha }} 是用於偏斜保護的建置引數。

  3. main.yaml 不發佈 chart 也不重新執行 PR 檢查。 分支保護需要 pr.yaml;main 僅產生成品。

release.yaml

  1. on: push: tags: ['v*.*.*'],然後依序執行:

    1. 除非標籤恰好是 vMAJOR.MINOR.PATCH 且其提交是 origin/main 的祖先,否則失敗。
    2. 不要重建。 如果 ghcr.io/nuvraxis/<app>:sha-<short> 不存在,則以「讓 main.yaml 完成,然後重新執行」的訊息失敗。無需回退建置。
    3. docker buildx imagetools create --tag :vX.Y.Z --tag :latest <sha-image>:這是一個清單層級的複製,會保留兩種架構、來源和 SBOM,且摘要相同。
    4. helm package --version X.Y.Z --app-version vX.Y.Z、helm push 到 oci://ghcr.io/nuvraxis/charts。
    5. gh release create vX.Y.Z --verify-tag --generate-notes,並附上 chart .tgz、image-digest.txt 和 sbom.spdx.json。
  2. 發佈流程: 合併到 main → 等待 main.yaml 變綠 → git tag vX.Y.Z && git push origin vX.Y.Z。在 main.yaml 完成之前標記會故意使步驟 2 失敗;一旦映像存在,重新執行發佈任務即可。錯誤的發佈透過新增 patch 標籤來修復,絕不透過移動標籤。

加速方法(僅在需要時使用)

  • QEMU 下的 arm64 是 main.yaml 的慢速部分。將其替換為在 ubuntu-24.04-arm + ubuntu-latest 上的矩陣,按摘要推送,然後使用 imagetools create 執行合併任務。保留標籤和單一索引。
  • pr.yaml 的 Turborepo 遠端快取:參閱 pnpm-turborepo。

驗證

docker run --rm -v "$PWD:/repo" -w /repo rhysd/actionlint:latest     # lint 所有工作流程
gh workflow list && gh run list --limit 5
gh run view <run-id> --log-failed

發佈之後:docker buildx imagetools inspect ghcr.io/nuvraxis/<app>:vX.Y.Z 會顯示兩個平台,而 helm show chart oci://ghcr.io/nuvraxis/charts/<app> --version X.Y.Z 會顯示 appVersion: vX.Y.Z。

來源

Individual skills in this repo

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

Nuvraxis/nuvraxis-plugins

>- Biome 2.5 setup and rules for Nuvraxis monorepos — root biome.json with pinned $schema, VCS ignore, formatter settings, the recommended preset with a11y and the react/next domains, nursery policy, organize imports, overrides, nested per-package configs ("extends": "//"), biome check --write locally, biome ci in CI, VS Code settings, and migrating from ESLint/Prettier. Use when the repo has biome.json or biome.jsonc, @biomejs/biome in package.json, .eslintrc*/eslint.config.*/.prettierrc* to migrate, or when fixing lint and formatting errors.

Nuvraxis/nuvraxis-plugins

>- Dockerfile rules for Next.js standalone apps in a pnpm + Turborepo monorepo — multi-stage build (turbo prune → pnpm fetch/offline install → turbo build → minimal runner), pinned Node 26 Alpine by digest, checksum-verified pnpm binary, non-root uid 1001, read-only root filesystem with a writable .next/cache, HEALTHCHECK on /api/health, build args only for NEXT_PUBLIC_* values, BuildKit secrets and cache mounts, multi-arch, OCI labels and .dockerignore. Use when the repo has a Dockerfile, .dockerignore, compose file, or next.config with output "standalone", or when asked to containerise, shrink, harden or debug an image.

Nuvraxis/nuvraxis-plugins

>- Helm chart rules for Nuvraxis Next.js apps — one chart per app in charts/ (named after the app), published to oci://ghcr.io/nuvraxis/charts and synced by Argo CD; Chart.yaml version/appVersion set only by release.yaml; Deployment with startup/liveness/readiness probes on /api/health, non-root read-only security context, emptyDir for .next/cache, ConfigMap + existing Secret via envFrom, Service, Ingress with cert-manager, HPA, PDB, ServiceAccount, topology spread; no Helm hooks; helm lint --strict + kubeconform. Use when the repo has charts/, Chart.yaml, values*.yaml, templates/*.yaml with Helm syntax, or an Argo CD Application, or when asked to deploy, scale, expose or configure the app on Kubernetes.

Nuvraxis/nuvraxis-plugins

>- Production rules for Next.js 16 App Router apps at Nuvraxis — Server/Client Component boundaries, Cache Components ("use cache", cacheLife, cacheTag, updateTag), Server Actions, route handlers, env handling, instrumentation, output standalone and the /api/health route. Use when the project has "next" in package.json, an app/ or src/app/ directory, next.config.ts, proxy.ts, instrumentation.ts, or files named page.tsx, layout.tsx, route.ts, loading.tsx, error.tsx.

相關技能