-
Notifications
You must be signed in to change notification settings - Fork 2
Cld 613/claude code init #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
55eca6c
1557695
4534849
59fa6db
32460e0
67f4b71
7130be9
5ba2834
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| name: List Open PRs | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| list-prs: | ||
| name: List Open Pull Requests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Authenticate to Google Cloud | ||
| id: auth | ||
| uses: google-github-actions/auth@v2.1.2 | ||
| with: | ||
| credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | ||
| create_credentials_file: true | ||
| export_environment_variables: true | ||
| env: | ||
| # Ensure credentials are created outside the git repository | ||
| GOOGLE_APPLICATION_CREDENTIALS_FILE_PATH: /tmp/gcp-credentials.json | ||
|
|
||
| - name: Set up Google Cloud SDK | ||
| uses: google-github-actions/setup-gcloud@v2.1.0 | ||
Check warningCode scanning / CodeQL Unpinned tag for a non-immutable Action in workflow Medium
Unpinned 3rd party Action 'Claude PR Review' step
Uses Step Error loading related location Loading |
||
| with: | ||
| project_id: ${{ secrets.GCP_PROJECT_ID }} | ||
|
|
||
| - name: Install Node.js | ||
| uses: actions/setup-node@v4.0.3 | ||
| with: | ||
| node-version: '22' | ||
|
|
||
| - name: Install Claude Code | ||
| run: | | ||
| npm install -g @anthropic-ai/claude-code | ||
| echo "Claude Code installed successfully" | ||
|
|
||
| - name: Configure Claude Code for Vertex AI | ||
| run: | | ||
|
Check failure on line 49 in .github/workflows/claude-code-review.yaml
|
||
| echo "CLAUDE_CODE_USE_VERTEX=1" >> $GITHUB_ENV | ||
| echo "CLOUD_ML_REGION=us-east5" >> $GITHUB_ENV | ||
| echo "ANTHROPIC_VERTEX_PROJECT_ID=${{ secrets.GCP_PROJECT_ID }}" >> $GITHUB_ENV | ||
| echo "DISABLE_PROMPT_CACHING=1" >> $GITHUB_ENV | ||
| echo "DISABLE_TELEMETRY=1" >> $GITHUB_ENV | ||
| echo "DISABLE_ERROR_REPORTING=1" >> $GITHUB_ENV | ||
| echo "DISABLE_BUG_COMMAND=1" >> $GITHUB_ENV | ||
| echo "CI=true" >> $GITHUB_ENV | ||
| echo "TERM=dumb" >> $GITHUB_ENV | ||
| echo "NO_COLOR=1" >> $GITHUB_ENV | ||
| echo "FORCE_COLOR=0" >> $GITHUB_ENV | ||
| echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV | ||
| echo "ANTHROPIC_MODEL=claude-sonnet-4@20250514" >> $GITHUB_ENV | ||
|
|
||
| - name: List Open Pull Requests with Claude Analysis | ||
| run: | | ||
|
Check failure on line 65 in .github/workflows/claude-code-review.yaml
|
||
| echo "=== Open Pull Requests Analysis by Claude ===" | ||
| echo "Repository: ${{ github.repository }}" | ||
| echo "Generated at: $(date)" | ||
| echo "" | ||
|
|
||
| # Get open PRs | ||
| curl -s \ | ||
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
| -H "Accept: application/vnd.github.v3+json" \ | ||
| "https://api.github.com/repos/${{ github.repository }}/pulls?state=open&per_page=100" \ | ||
| > open_prs.json | ||
|
|
||
| PR_COUNT=$(cat open_prs.json | jq length) | ||
| echo "Total open PRs: $PR_COUNT" | ||
| echo "" | ||
|
|
||
| if [ "$PR_COUNT" -eq 0 ]; then | ||
| echo "🎉 No open pull requests!" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Process each PR with Claude analysis | ||
| cat open_prs.json | jq -c '.[]' | while read -r pr; do | ||
| PR_NUMBER=$(echo "$pr" | jq -r '.number') | ||
| PR_TITLE=$(echo "$pr" | jq -r '.title') | ||
| PR_AUTHOR=$(echo "$pr" | jq -r '.user.login') | ||
| PR_URL=$(echo "$pr" | jq -r '.html_url') | ||
| PR_BODY=$(echo "$pr" | jq -r '.body // "No description provided"') | ||
| PR_CREATED=$(echo "$pr" | jq -r '.created_at') | ||
| DRAFT=$(echo "$pr" | jq -r '.draft') | ||
|
|
||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| echo "🔄 PR #$PR_NUMBER: $PR_TITLE" | ||
| echo "👤 Author: @$PR_AUTHOR" | ||
| echo "🔗 URL: $PR_URL" | ||
| echo "📅 Created: $PR_CREATED" | ||
| if [ "$DRAFT" == "true" ]; then | ||
| echo "🚧 Status: DRAFT" | ||
| else | ||
| echo "✅ Status: Ready for Review" | ||
| fi | ||
| echo "" | ||
|
|
||
| # Get PR diff for Claude analysis | ||
| curl -s \ | ||
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
| -H "Accept: application/vnd.github.diff" \ | ||
| "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \ | ||
| > "pr_${PR_NUMBER}.diff" | ||
|
|
||
| # Get files changed for context | ||
| curl -s \ | ||
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
| -H "Accept: application/vnd.github.v3+json" \ | ||
| "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/files" \ | ||
| > "pr_${PR_NUMBER}_files.json" | ||
|
|
||
| FILES_COUNT=$(cat "pr_${PR_NUMBER}_files.json" | jq length) | ||
|
|
||
| # Create analysis prompt for Claude | ||
| cat > "claude_prompt_${PR_NUMBER}.txt" << EOF | ||
| Please analyze this pull request and provide a concise summary. | ||
|
|
||
| PR Title: $PR_TITLE | ||
| PR Description: $PR_BODY | ||
| Files changed: $FILES_COUNT | ||
|
|
||
| Key files modified: | ||
| $(cat "pr_${PR_NUMBER}_files.json" | jq -r '.[] | "- \(.filename) (\(.status)) +\(.additions)/-\(.deletions)"' | head -10) | ||
|
|
||
| Please provide: | ||
| 1. A brief summary of what this PR does (2-3 sentences) | ||
| 2. The main technical changes or features added | ||
| 3. Any potential impact or risks you notice | ||
| 4. Overall assessment (bug fix, feature, refactor, etc.) | ||
|
|
||
| Keep the response concise and focused on the key changes. | ||
| EOF | ||
|
|
||
| echo "🤖 Claude Analysis:" | ||
|
|
||
| # Create temp directory outside git repository for Claude prompt | ||
| TEMP_DIR="/tmp/claude-pr-${PR_NUMBER}-$$" | ||
| mkdir -p "$TEMP_DIR" | ||
|
|
||
| # Move the prompt to temp directory | ||
| mv "claude_prompt_${PR_NUMBER}.txt" "$TEMP_DIR/claude_prompt.txt" | ||
|
|
||
| # Use Claude Code CLI with Vertex AI configuration | ||
| cd "$TEMP_DIR" | ||
| CLAUDE_RESPONSE=$(claude -p "$(cat claude_prompt.txt)" --output-format stream-json --verbose 2>&1 | tail -n 20) | ||
| cd - > /dev/null | ||
|
|
||
| if [ $? -eq 0 ]; then | ||
| # Claude succeeded - display the response | ||
| echo "$CLAUDE_RESPONSE" | sed 's/^/ /' | ||
| else | ||
| echo " Claude analysis failed. Error output:" | ||
| echo "$CLAUDE_RESPONSE" | sed 's/^/ /' | ||
| echo "" | ||
| echo " Fallback: Basic analysis based on file changes" | ||
| echo " This PR modifies $FILES_COUNT file(s) in the repository." | ||
| echo " Manual review recommended for detailed assessment." | ||
| fi | ||
|
|
||
| # Cleanup temp directory | ||
| rm -rf "$TEMP_DIR" | ||
|
|
||
| echo "" | ||
| echo "📁 Files Summary: $FILES_COUNT file(s) changed" | ||
| if [ "$FILES_COUNT" -gt 0 ]; then | ||
| cat "pr_${PR_NUMBER}_files.json" | jq -r '.[] | " • \(.filename) (\(.status))"' | head -5 | ||
| if [ "$FILES_COUNT" -gt 5 ]; then | ||
| echo " ... and $((FILES_COUNT - 5)) more files" | ||
| fi | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "" | ||
|
|
||
| # Clean up temp files | ||
| rm -f "pr_${PR_NUMBER}.diff" "pr_${PR_NUMBER}_files.json" | ||
| done | ||
|
|
||
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | ||
| echo "🎯 Analysis complete! Found $PR_COUNT open pull request(s) analyzed by Claude." | ||
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium