Skip to content

feat: update Claude workflow to run after CI completion - #269

Merged
keito4 merged 2 commits into
mainfrom
feat/update-claude-workflow-ci-dependency
Jan 2, 2026
Merged

feat: update Claude workflow to run after CI completion#269
keito4 merged 2 commits into
mainfrom
feat/update-claude-workflow-ci-dependency

Conversation

@keito4

@keito4 keito4 commented Jan 2, 2026

Copy link
Copy Markdown
Owner

Summary

Claude Code reviewを他のCIが全て通った後にのみ実行するように変更しました。

変更内容

新規追加

  • check-ci-status ジョブ: PRの場合、CIステータスをチェック

    • PRのHEAD SHAを取得
    • GitHub Status APIでCIステータスを確認
    • CIが成功している場合のみ次のジョブを実行
  • script/update-claude-workflow-multi-repo.sh: 全リポジトリにclaude.ymlの変更を適用するスクリプト

更新

  • claude ジョブ:

    • check-ci-status ジョブに依存
    • Issueへのコメント(PRではない)の場合は直接実行
    • PRへのコメントの場合はCIが完了している場合のみ実行
  • concurrency設定:

    • より詳細なグループ化によりPR/Issue単位で並行実行を制御

動作

  1. Issueへの@claudeコメント: CIチェック不要、即座に実行
  2. PRへの@claudeコメント: CIステータスをチェックし、成功している場合のみ実行
  3. CI未完了の場合: Claude実行をスキップし、待機メッセージを表示

Test plan

  • Issueへの@claudeコメントが正しく動作することを確認
  • PRへの@claudeコメント(CI完了後)が正しく動作することを確認
  • PRへの@claudeコメント(CI未完了)がスキップされることを確認
  • CIステータスチェックが正しく動作することを確認

次のステップ

このPRがマージされた後、script/update-claude-workflow-multi-repo.sh を実行して
以下のリポジトリに同じ変更を適用します:

  • Elu-co-jp/cyber_ace_1on1
  • Elu-co-jp/pulse_survey
  • Elu-co-jp/management_tools
  • Elu-co-jp/job_description
  • Elu-co-jp/opt_ai_manager
  • keito4-org/n8n_custom_node
  • Elu-co-jp/cloud_provisioning
  • keito4/config (このリポジトリ)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved the PR gating and CI-read checks for the assistant workflow to make triggers more reliable and safe.
    • Expanded workflow permissions and concurrency handling for clearer, more robust processing across PRs.
  • New Feature
    • Added a maintenance script to propagate the updated assistant workflow across multiple repositories automatically.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 2, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@keito4 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 89d4f0b and c055760.

📒 Files selected for processing (2)
  • .github/workflows/claude-code-review.yml
  • .github/workflows/claude.yml
📝 Walkthrough
📝 Walkthrough

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating the Claude workflow to conditionally run after CI completion for PRs, which is the core purpose of the changeset.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

steps:
- name: Get PR number
id: pr
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:2:53: Double quote to prevent globbing and word splitting [shellcheck]

steps:
- name: Get PR number
id: pr
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:4:60: Double quote to prevent globbing and word splitting [shellcheck]

steps:
- name: Get PR number
id: pr
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:6:60: Double quote to prevent globbing and word splitting [shellcheck]

id: check
env:
GH_TOKEN: ${{ github.token }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2034:warning:11:1: CHECKS appears unused. Verify use (or export if used externally) [shellcheck]

id: check
env:
GH_TOKEN: ${{ github.token }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:11:37: Double quote to prevent globbing and word splitting [shellcheck]

id: check
env:
GH_TOKEN: ${{ github.token }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:14:40: Double quote to prevent globbing and word splitting [shellcheck]

id: check
env:
GH_TOKEN: ${{ github.token }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:20:28: Double quote to prevent globbing and word splitting [shellcheck]

id: check
env:
GH_TOKEN: ${{ github.token }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:23:29: Double quote to prevent globbing and word splitting [shellcheck]

@claude

claude Bot commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

Pull Request Review

このPRを詳細にレビューしました。全体的に良い実装ですが、いくつかの改善点とセキュリティ上の懸念があります。


✅ 良い点

  1. 明確な目的: Claude Code reviewをCIが成功した後にのみ実行するという目的が明確
  2. 適切な分離: check-ci-status ジョブを分離することで責任が明確化
  3. 包括的なドキュメント: PR本文とスクリプトのコメントが充実
  4. 並行実行制御の改善: concurrencyグループがより詳細になり、PR/Issue単位での制御が可能

⚠️ 改善が必要な点

1. CI Status チェックのロジックに潜在的な問題 (.github/workflows/claude.yml:42-63)

問題:

  • CHECKS 変数を取得していますが、実際には使用されていません
  • CI_STATUS が空文字列の場合を成功と判定していますが、これは「CIが実行されていない」状態も含む可能性があり、期待と異なる動作になる可能性があります

推奨: CI_STATUSが空文字列またはnullの場合の処理を明示的に分岐させる

2. 条件式の冗長性と可読性 (.github/workflows/claude.yml:76-84)

この条件式は複雑で理解しにくいです。また、|| '' のフォールバック処理が一貫していません。

3. エラーハンドリングの不足 (script/update-claude-workflow-multi-repo.sh)

問題: スクリプトは複数のリポジトリを処理しますが、個別の失敗を記録・報告する仕組みが不十分です。

推奨: 成功/失敗を追跡し、最後にサマリーを出力

4. 権限の最小化原則 (.github/workflows/claude.yml:19-21)

問題: check-ci-status ジョブに pull-requests: read 権限が付与されていますが、実際にはPR情報を直接読み取っていません(gh api コマンドで対応可能)。


🔒 セキュリティ上の懸念

1. 中程度: GitHub Token の権限スコープ

スクリプト内で GH_TOKEN を使用していますが、このトークンの権限範囲が明確ではありません。トークンの権限を明示的に制限し、ドキュメント化してください。

2. 低: シェルスクリプトのインジェクションリスク

配列が静的定義のため実際のリスクは低いです(問題なし)。


🧪 テストカバレッジに関する懸念

重大な問題: このPRにはテストが含まれていません。

CLAUDE.mdの品質基準に基づき、以下が必要です:

  1. Integration Tests: GitHub Actions ワークフローの動作を検証する統合テスト
  2. Unit Tests: シェルスクリプトのロジックをテストする単体テスト(BATS等)

📊 パフォーマンスに関する考慮事項

  1. タイムアウト設定: check-ci-status ジョブのタイムアウトが5分は適切
  2. API Rate Limiting: gh api コマンドを複数回実行していますが、GitHub APIのレート制限に注意が必要です

📝 ドキュメンテーション

以下のドキュメント更新を推奨します:

  1. CLAUDE.md に新しいワークフローの動作を記載
  2. README.mdscript/update-claude-workflow-multi-repo.sh の使用方法を追加
  3. トラブルシューティングガイド: CIが失敗した場合のClaudeの動作について

🎯 次のステップ

マージ前に必須

  1. ✅ CI Status チェックのロジックを修正(空文字列の扱い)
  2. ✅ 統合テストを追加(最低限の動作検証)
  3. ✅ エラーハンドリングを改善(スクリプト)

マージ後に推奨

  1. 📚 ドキュメント更新
  2. 🧪 包括的なテストスイートの追加
  3. 📊 モニタリング: 実際の動作を確認し、必要に応じて調整

総評

現状: 条件付き承認 ⚠️

基本的な実装は良好ですが、上記の改善点(特にCI Status チェックのロジックとテストカバレッジ)に対処することを強く推奨します。

CLAUDE.mdの品質基準(TDD、70%+カバレッジ)を満たすために、テストの追加は必須です。

ご質問があればお気軽にお尋ねください!

@keito4
keito4 force-pushed the feat/update-claude-workflow-ci-dependency branch from 1bc113a to de552d6 Compare January 2, 2026 05:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
script/update-claude-workflow-multi-repo.sh (3)

96-98: Consider handling existing remote branches.

If a previous run created the branch but failed before completing, subsequent runs will fail when pushing. Consider checking for existing remote branches or using force push with lease.

🔎 Proposed enhancement
   # 新しいブランチを作成
   log_info "Creating branch: $BRANCH_NAME"
+  # Check if branch exists remotely and delete if so
+  if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then
+    log_warning "Branch $BRANCH_NAME already exists on remote, deleting..."
+    git push origin --delete "$BRANCH_NAME" 2>/dev/null || true
+  fi
   git checkout -b "$BRANCH_NAME"

153-209: Handle existing PRs gracefully.

If a PR already exists for the branch (from a previous partial run), gh pr create will fail. Consider checking for existing PRs or using gh pr create with error handling.

🔎 Proposed enhancement
   # PR作成
   log_info "Creating pull request..."
+  # Check if PR already exists
+  EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json url --jq '.[0].url' 2>/dev/null || echo "")
+  if [ -n "$EXISTING_PR" ]; then
+    log_warning "PR already exists: $EXISTING_PR"
+    PR_URL="$EXISTING_PR"
+  else
   PR_URL=$(gh pr create \
     --title "feat: update Claude workflow to run after CI completion" \
     --body "$(cat <<'EOF'
   ...
   EOF
   )" \
     --base "$default_branch" 2>&1)
+  fi

   log_success "PR created: $PR_URL"

214-218: Consider tracking success/skip/failure counts.

The summary only shows total repositories. Tracking and displaying how many succeeded, were skipped (no claude.yml or no changes), or failed would improve visibility.

🔎 Proposed enhancement

Add counters at the start of the script:

SUCCESS_COUNT=0
SKIP_COUNT=0
FAIL_COUNT=0

Increment appropriately throughout the loop, then update the summary:

 log_success "All repositories processed!"
 echo ""
 echo "Summary:"
 echo "- Total repositories: ${#REPOS[@]}"
+echo "- Successful: $SUCCESS_COUNT"
+echo "- Skipped: $SKIP_COUNT"
+echo "- Failed: $FAIL_COUNT"
 echo "- Work directory: $WORK_DIR (will be cleaned up)"
.github/workflows/claude.yml (1)

58-59: Unused variable CHECKS.

The CHECKS variable is set but never used in the subsequent logic. Either remove it or use it for more granular check status verification.

🔎 Proposed fix - remove unused variable
-          # Check runsを取得
-          CHECKS=$(gh api repos/$REPO/commits/$HEAD_SHA/check-runs --jq '.check_runs[] | select(.name == "CI" or .name == "build" or .name == "test" or .name == "lint")')
-
           # CIワークフローのステータスを取得
           CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3c954f and 1bc113a.

📒 Files selected for processing (2)
  • .github/workflows/claude.yml
  • script/update-claude-workflow-multi-repo.sh
🧰 Additional context used
📓 Path-based instructions (1)
.github/workflows/claude.yml

📄 CodeRabbit inference engine (CLAUDE.md)

Trigger automatic AI assistance on @claude mentions in issues, PRs, and comments using .github/workflows/claude.yml

Files:

  • .github/workflows/claude.yml
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml

Applied to files:

  • script/update-claude-workflow-multi-repo.sh
  • .github/workflows/claude.yml
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml

Applied to files:

  • script/update-claude-workflow-multi-repo.sh
  • .github/workflows/claude.yml
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/ci.yml : Validate code quality in CI pipeline (.github/workflows/ci.yml) with linting, formatting, testing, and building

Applied to files:

  • .github/workflows/claude.yml
📚 Learning: 2025-12-09T08:39:14.049Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T08:39:14.049Z
Learning: Follow development quality standards defined in `CLAUDE.md` when using Claude Code for development assistance

Applied to files:

  • .github/workflows/claude.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: claude-review
🔇 Additional comments (6)
script/update-claude-workflow-multi-repo.sh (3)

1-10: Good use of strict mode and variable setup.

The script uses set -euo pipefail which is excellent for catching errors early. The use of $$ in WORK_DIR ensures unique temporary directories for concurrent executions.


60-65: Good cleanup handling with trap.

The cleanup trap ensures the temporary work directory is removed even if the script fails, which prevents disk space leaks.


149-151: Push may fail silently on branch protection.

If target repositories have branch protection rules preventing direct pushes to feature branches, this will fail. The set -e will cause the script to stop. Consider adding explicit error handling with a helpful message.

.github/workflows/claude.yml (3)

13-15: Improved concurrency grouping.

The updated concurrency key now includes repository and issue/PR number, which provides better isolation between different PRs/Issues in the same repository.


76-85: Correct conditional logic for job execution.

The conditions properly handle all scenarios:

  • Issues trigger Claude directly (skipped CI check)
  • PR comments require successful CI
  • The always() combined with explicit result checks ensures correct flow control.

88-110: Permissions correctly configured at both levels.

The checks: read permission is appropriately added both at the job level (for the job to access checks) and in additional_permissions (for the Claude action to inherit). This follows the principle of least privilege.

Comment on lines +61 to +74
# CIワークフローのステータスを取得
CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')

echo "CI Status: $CI_STATUS"

# CIが成功している、またはチェックが存在しない場合は許可
if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then
echo "ci_passed=true" >> $GITHUB_OUTPUT
echo "✅ CI checks passed or not required"
else
echo "ci_passed=false" >> $GITHUB_OUTPUT
echo "❌ CI checks have not passed yet. Current status: $CI_STATUS"
echo "Please wait for CI to complete before running Claude Code."
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

API failure could incorrectly allow execution.

If the gh api call to get CI status fails (network issue, rate limit, etc.), CI_STATUS may be empty, causing ci_passed=true. Consider validating the API response.

🔎 Proposed fix with error handling
           # CIワークフローのステータスを取得
-          CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')
+          CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state') || {
+            echo "ci_passed=false" >> $GITHUB_OUTPUT
+            echo "❌ Failed to fetch CI status"
+            exit 0
+          }

           echo "CI Status: $CI_STATUS"

           # CIが成功している、またはチェックが存在しない場合は許可
-          if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then
+          if [ "$CI_STATUS" = "success" ] || [ -z "$CI_STATUS" ]; then
             echo "ci_passed=true" >> $GITHUB_OUTPUT
             echo "✅ CI checks passed or not required"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# CIワークフローのステータスを取得
CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')
echo "CI Status: $CI_STATUS"
# CIが成功している、またはチェックが存在しない場合は許可
if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then
echo "ci_passed=true" >> $GITHUB_OUTPUT
echo "✅ CI checks passed or not required"
else
echo "ci_passed=false" >> $GITHUB_OUTPUT
echo "❌ CI checks have not passed yet. Current status: $CI_STATUS"
echo "Please wait for CI to complete before running Claude Code."
fi
# CIワークフローのステータスを取得
CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state') || {
echo "ci_passed=false" >> $GITHUB_OUTPUT
echo "❌ Failed to fetch CI status"
exit 0
}
echo "CI Status: $CI_STATUS"
# CIが成功している、またはチェックが存在しない場合は許可
if [ "$CI_STATUS" = "success" ] || [ -z "$CI_STATUS" ]; then
echo "ci_passed=true" >> $GITHUB_OUTPUT
echo "✅ CI checks passed or not required"
else
echo "ci_passed=false" >> $GITHUB_OUTPUT
echo "❌ CI checks have not passed yet. Current status: $CI_STATUS"
echo "Please wait for CI to complete before running Claude Code."
fi
🤖 Prompt for AI Agents
.github/workflows/claude.yml around lines 61 to 74: the script treats an empty
CI_STATUS as success which lets execution proceed when the gh api call actually
failed; change the logic to detect API failure by checking the gh api command
exit code (or HTTP response) before trusting CI_STATUS, and only set
ci_passed=true when the API succeeded and returned "success" or an explicit "no
status" indicator; on gh api failure, set ci_passed=false and log the error/exit
code and response so execution is blocked and the failure is visible.

@keito4
keito4 force-pushed the feat/update-claude-workflow-ci-dependency branch from de552d6 to 89d4f0b Compare January 2, 2026 05:30
@keito4

keito4 commented Jan 2, 2026

Copy link
Copy Markdown
Owner Author

(aside)
@claude PRがbaseにマージする際にCIが落ちています。
修正してください。

@claude

claude Bot commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

Claude finished @keito4's task in 2m 44s —— View job


CI修正完了(手動適用が必要)

実施内容

CI失敗の原因であるshellcheck警告をすべて修正しました。ただし、GitHub Appの権限制限により.github/workflows/配下のファイルを直接プッシュできないため、手動での適用が必要です。

修正内容

1. script/update-claude-workflow-multi-repo.sh
  • 84行目: cdコマンドにエラーハンドリングを追加
    - cd "$repo_dir"
    + cd "$repo_dir" || exit
2. .github/workflows/claude.yml
  • 変数のクォート: $GITHUB_OUTPUT"$GITHUB_OUTPUT" (4箇所)
  • 未使用変数の削除: CHECKS変数を削除(2行)
  • APIパスのクォート: gh apiの引数をクォート (2箇所)
📋 完全なdiff
diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml
index c20d7c7..85a846f 100644
--- a/.github/workflows/claude.yml
+++ b/.github/workflows/claude.yml
@@ -34,11 +34,11 @@ jobs:
         id: pr
         run: |
           if [ "${{ github.event_name }}" = "issue_comment" ]; then
-            echo "number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
+            echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
           elif [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then
-            echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
+            echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
           elif [ "${{ github.event_name }}" = "pull_request_review" ]; then
-            echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
+            echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
           fi
 
       - name: Check CI status
@@ -50,25 +50,22 @@ jobs:
           REPO="${{ github.repository }}"
 
           # PRのHEAD SHAを取得
-          PR_DATA=$(gh api repos/$REPO/pulls/$PR_NUMBER)
+          PR_DATA=$(gh api "repos/$REPO/pulls/$PR_NUMBER")
           HEAD_SHA=$(echo "$PR_DATA" | jq -r '.head.sha')
 
           echo "Checking CI status for PR #$PR_NUMBER (SHA: $HEAD_SHA)"
 
-          # Check runsを取得
-          CHECKS=$(gh api repos/$REPO/commits/$HEAD_SHA/check-runs --jq '.check_runs[] | select(.name == "CI" or .name == "build" or .name == "test" or .name == "lint")')
-
           # CIワークフローのステータスを取得
-          CI_STATUS=$(gh api repos/$REPO/commits/$HEAD_SHA/status --jq '.state')
+          CI_STATUS=$(gh api "repos/$REPO/commits/$HEAD_SHA/status" --jq '.state')
 
           echo "CI Status: $CI_STATUS"
 
           # CIが成功している、またはチェックが存在しない場合は許可
           if [ "$CI_STATUS" = "success" ] || [ "$CI_STATUS" = "" ]; then
-            echo "ci_passed=true" >> $GITHUB_OUTPUT
+            echo "ci_passed=true" >> "$GITHUB_OUTPUT"
             echo "✅ CI checks passed or not required"
           else
-            echo "ci_passed=false" >> $GITHUB_OUTPUT
+            echo "ci_passed=false" >> "$GITHUB_OUTPUT"
             echo "❌ CI checks have not passed yet. Current status: $CI_STATUS"
             echo "Please wait for CI to complete before running Claude Code."
           fi
diff --git a/script/update-claude-workflow-multi-repo.sh b/script/update-claude-workflow-multi-repo.sh
index 2bf0e6e..768fe8a 100755
--- a/script/update-claude-workflow-multi-repo.sh
+++ b/script/update-claude-workflow-multi-repo.sh
@@ -81,7 +81,7 @@ for repo in "${REPOS[@]}"; do
     continue
   fi
 
-  cd "$repo_dir"
+  cd "$repo_dir" || exit
 
   # デフォルトブランチを取得
   default_branch=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')

適用方法

以下のいずれかの方法で修正を適用してください:

方法1: ローカルで手動編集
  1. 上記のdiffを参考に2つのファイルを編集
  2. コミット&プッシュ
    git add script/update-claude-workflow-multi-repo.sh .github/workflows/claude.yml
    git commit -m "fix: resolve shellcheck warnings"
    git push origin feat/update-claude-workflow-ci-dependency
方法2: パッチファイルを使用

ローカルリポジトリで以下を実行:

# ブランチをチェックアウト
git checkout feat/update-claude-workflow-ci-dependency

# 上記のdiffをpatch.diffとして保存し、適用
git apply patch.diff
git add -A
git commit -m "fix: resolve shellcheck warnings"
git push origin feat/update-claude-workflow-ci-dependency

期待される結果

修正適用後、shellcheckの警告がすべて解消され、CI(Lint & Format ジョブ)が通過します。


| Branch

Claude Code reviewを他のCIが全て通った後にのみ実行するように
変更しました。

## 変更内容

### 新規追加
- `check-ci-status` ジョブ: PRの場合、CIステータスを
  チェック
  - PRのHEAD SHAを取得
  - GitHub Status APIでCIステータスを確認
  - CIが成功している場合のみ次のジョブを実行

### 更新
- `claude` ジョブ:
  - `check-ci-status` ジョブに依存
  - Issueへのコメント(PRではない)の場合は直接実行
  - PRへのコメントの場合はCIが完了している場合のみ実行

### concurrency設定
- より詳細なグループ化によりPR/Issue単位で並行実行を
  制御

## 動作

1. **Issueへの@claudeコメント**:
   CIチェック不要、即座に実行
2. **PRへの@claudeコメント**:
   CIステータスをチェックし、成功している場合のみ実行
3. **CI未完了の場合**:
   Claude実行をスキップし、待機メッセージを表示

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@keito4
keito4 force-pushed the feat/update-claude-workflow-ci-dependency branch from 89d4f0b to 4e36bae Compare January 2, 2026 05:33
@claude

claude Bot commented Jan 2, 2026

Copy link
Copy Markdown
Contributor

Claude Code によるPRレビュー

このPRは、Claude Code ワークフローを他のCIが完了した後にのみ実行するように改善するものです。全体的に良い設計ですが、いくつか改善点と懸念事項があります。

✅ 良い点

  1. 適切な責務分離: check-ci-status ジョブと claude ジョブを分離
  2. concurrency設定の改善: PR/Issue単位でのグループ化 (.github/workflows/claude.yml:14)
  3. always() の使用: 前のジョブがスキップされた場合も適切に処理 (.github/workflows/claude.yml:79)
  4. 明確なフィードバック: CIステータスチェック時にメッセージを表示 (.github/workflows/claude.yml:69-73)

⚠️ 潜在的な問題

1. CI ステータスチェックのロジックに問題あり (重要度: 高)

.github/workflows/claude.yml:59-62 のチェックロジックに問題があります。CHECKS 変数を取得しているが使用していない、また status API は GitHub Status API (古い仕組み) を使用しており、GitHub Actions の Check Runs とは異なります。このリポジトリのCIワークフロー名は CI なので、Check Runs APIを使うべきです。

推奨: Check Runs APIから直接 conclusion フィールドを取得し、それが success または空の場合のみ許可する

2. CI未完了時の動作が不明確 (重要度: 中)

.github/workflows/claude.yml:82-83 で、ci_passed == true の場合のみClaudeを実行していますが、CIが pending や failure の場合の処理が明示的ではありません。

推奨: CI失敗時にPRにコメントを残す、またはジョブを失敗させる

3. check-ci-status のスキップ条件 (重要度: 低)

.github/workflows/claude.yml:83 の条件が一部冗長ですが、防御的プログラミングとしては問題ありません。コメントで意図を説明することを推奨します。

4. null-safety 対策の一貫性 (重要度: 低)

一部で null-safety 対策が不一致です。すべての箇所で一貫性を持たせることを推奨します。

🔒 セキュリティ

  • 権限設定は適切: check-ci-status ジョブは読み取り専用権限のみ使用 (.github/workflows/claude.yml:28-31)
  • トークンスコープも適切: GH_TOKEN は GitHub Actions の自動トークンを使用

📊 テストカバレッジ

PRの説明にテスト計画が記載されていますが、実際のテストは未実装です。

推奨: ワークフローの統合テストを手動で実施するか、テスト用のPRを作成して動作確認を行ってください。

📝 ドキュメント

欠落している項目:

  1. script/update-claude-workflow-multi-repo.sh: PR本文で言及されていますが、このPRには含まれていません
  2. CLAUDE.md の更新: この変更により、Claude Code の動作が変わるため記載すべき

🎯 推奨事項

優先度: 高

  1. CIステータスチェックロジックの修正: Status API ではなく Check Runs API を正しく使用する
  2. update-claude-workflow-multi-repo.sh スクリプトの追加または別PR対応を明記

優先度: 中
3. CI未完了時の明示的な通知
4. 統合テストの実施

優先度: 低
5. null-safety の一貫性向上
6. コメントによる意図の明確化

全体として、このPRはClaude Code ワークフローの実行タイミングを最適化する良いアプローチです。上記の問題を修正すれば、本番環境にデプロイできる品質になります。

claude-code-review.yml が他のCIが全て通った後にのみ
実行されるように変更しました。

## 変更内容

### 新規追加
- `check-ci-status` ジョブ: CIステータスをチェック
  - PRのHEAD SHAを取得
  - GitHub Status APIでCIステータスを確認
  - CIが成功している場合のみ次のジョブを実行

### 更新
- `claude-review` ジョブ:
  - `check-ci-status` ジョブに依存
  - CIが成功した場合のみ実行

## 動作

1. **PRが作成/更新されたとき**:
   check-ci-statusジョブが実行される
2. **CIが成功している場合**:
   claude-reviewジョブが実行される
3. **CIが未完了/失敗の場合**:
   claude-reviewジョブはスキップされる

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:14:28: Double quote to prevent globbing and word splitting [shellcheck]

id: check
env:
GH_TOKEN: ${{ github.token }}
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:17:29: Double quote to prevent globbing and word splitting [shellcheck]

@keito4
keito4 merged commit 94a24de into main Jan 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant