From 8a8ba804425e940b61dc7ee28ca65824e7b6899e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Mar 2026 20:56:01 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20required=20status=20checks=20?= =?UTF-8?q?=E3=82=92=E5=AE=9F=E9=9A=9B=E3=81=AE=20CI=20=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=96=E5=90=8D=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - setup-team-protection.sh の contexts を "CI" → "Quality Gate" に変更 Quality Gate ジョブが全チェックを集約し if: always() で常に実行されるため最適 - Next.js プロジェクト向けに pre-production/production ブランチの保護を推奨に追加 - repo-maintenance の必須ジョブ参照を Quality Gate ベースに更新 Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/commands/repo-maintenance.md | 27 +++++++++++++++++++++-- .claude/commands/setup-team-protection.md | 20 ++++++++++++++--- script/setup-team-protection.sh | 4 +++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/.claude/commands/repo-maintenance.md b/.claude/commands/repo-maintenance.md index 9b0276f4..cc39a21b 100644 --- a/.claude/commands/repo-maintenance.md +++ b/.claude/commands/repo-maintenance.md @@ -277,16 +277,39 @@ GitHub リポジトリの保護ルールを確認・設定: 実行内容: - ブランチ保護ルールの確認 -- 必須ステータスチェックの設定 +- 必須ステータスチェックの設定(`Quality Gate` ジョブ) - レビュー要件の設定 - Dependabot、脆弱性アラートの有効化 +- Next.js プロジェクトの場合、`pre-production` / `production` ブランチの保護確認 これは `/setup-team-protection` コマンドと同等の処理を実行します。 +**フレームワーク検出による保護ブランチの自動判定:** + +```bash +# Next.js プロジェクトかどうかを検出 +IS_NEXTJS=false +if [ -f "package.json" ]; then + if jq -e '.dependencies.next // .devDependencies.next' package.json &>/dev/null; then + IS_NEXTJS=true + fi +fi + +# Next.js の場合は pre-production / production も保護対象 +if [ "$IS_NEXTJS" = true ]; then + PROTECT_BRANCHES="main,pre-production,production" + PROTECTION_LEVEL="strict" +else + PROTECT_BRANCHES="main" + PROTECTION_LEVEL="standard" +fi +``` + 結果: - ✅ 保護ルール設定済み - ⚠️ 未設定の保護ルールあり(詳細をリスト) +- ⚠️ Next.js プロジェクト: `pre-production` / `production` ブランチ未保護 → strict レベルで保護を提案 - 🔧 設定を適用 ### 3.2 Husky Setup Check @@ -567,7 +590,7 @@ CI/CD ワークフローの設定状況を確認: 実行内容: - GitHub Actions ワークフローの存在確認 -- 必須ジョブ(lint, test, build)の確認 +- 必須ジョブ(Quality Gate による全チェック集約)の確認 - セキュリティスキャンの設定確認 - Claude Code Review の統合確認 diff --git a/.claude/commands/setup-team-protection.md b/.claude/commands/setup-team-protection.md index 41b2c5be..0f6da9fd 100644 --- a/.claude/commands/setup-team-protection.md +++ b/.claude/commands/setup-team-protection.md @@ -82,7 +82,7 @@ bash script/setup-team-protection.sh --dry-run gh api repos/{owner}/{repo}/branches/main/protection \ --method PUT \ --field required_status_checks[strict]=true \ - --field required_status_checks[contexts][]=CI \ + --field required_status_checks[contexts][]="Quality Gate" \ --field required_pull_request_reviews[required_approving_review_count]=1 \ --field required_pull_request_reviews[dismiss_stale_reviews]=true \ --field required_pull_request_reviews[require_code_owner_reviews]=false \ @@ -95,8 +95,8 @@ gh api repos/{owner}/{repo}/branches/main/protection \ **必須ステータスチェック** -以下のワークフローが必須: -• CI(テスト、リント、ビルド) +以下のチェックが必須: +• Quality Gate(CI ワークフローの全ジョブ結果を集約するゲートジョブ) • セキュリティスキャン(オプション) **レビュー要件** @@ -241,6 +241,20 @@ Error: Branch not found 3. main ブランチに適用 4. 必要に応じて厳格化 +**フレームワーク別の推奨ブランチ保護** + +• Next.js / Vercel プロジェクト: +`main`, `pre-production`, `production` の3ブランチを保護(strict レベル推奨) + +```bash +bash script/setup-team-protection.sh \ + --branches main,pre-production,production \ + --create-branches \ + --protection-level strict +``` + +• それ以外のプロジェクト: `main` のみ(デフォルト) + **チームサイズに応じた設定** • 小規模チーム(2-5名): レビュー1名 diff --git a/script/setup-team-protection.sh b/script/setup-team-protection.sh index 64c41428..de5bdf60 100755 --- a/script/setup-team-protection.sh +++ b/script/setup-team-protection.sh @@ -232,7 +232,9 @@ setup_branch_protection() { if [[ "$SKIP_STATUS_CHECKS" == "false" ]]; then protection_config+='"strict":true,' - protection_config+='"contexts":["CI"]' + # CI workflow の Quality Gate ジョブが全チェックを集約するため、 + # 単一の required check として使用する + protection_config+='"contexts":["Quality Gate"]' else protection_config+='"strict":false,' protection_config+='"contexts":[]' From 88f071dc9d77ca8a5a25ebe26cf2e150851cd8d4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Mar 2026 21:04:23 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20checkout=20=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E3=81=AA=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=82=92=E3=83=86=E3=82=B9=E3=83=88=E3=81=8B=E3=82=89=E9=99=A4?= =?UTF-8?q?=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dependabot-auto-merge.yml と release-drafter.yml はリポジトリの チェックアウトが不要なため、checkout action のチェックから除外 Co-Authored-By: Claude Opus 4.6 (1M context) --- test/integration/workflows.bats | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration/workflows.bats b/test/integration/workflows.bats index e977ce57..e433de5c 100644 --- a/test/integration/workflows.bats +++ b/test/integration/workflows.bats @@ -113,9 +113,15 @@ load ../test_helper/test_helper @test "all workflows use checkout action" { local workflows_dir="${REPO_ROOT}/.github/workflows" + # Workflows that don't need checkout (no source code access required) + local skip_patterns="dependabot-auto-merge|release-drafter" for workflow in "$workflows_dir"/*.yml; do - # Every workflow should checkout the repository + local basename + basename=$(basename "$workflow") + if echo "$basename" | grep -qE "$skip_patterns"; then + continue + fi if grep -q "^jobs:" "$workflow"; then grep -q "actions/checkout@" "$workflow" fi