feat: enhance Claude issue workflow with robust PR creation

- Improve change detection to check both staged and unstaged changes
- Add detailed file listing in PR description
- Include comprehensive review checklist with build/lint checks
- Add fallback PR creation mechanism for error resilience
- Enhance success messaging with detailed implementation summary
- Add debugging output for change detection
- Include deployment instructions in PR template

Key improvements:
- More robust change detection
- Error handling with fallback PR creation
- Better PR descriptions with changed files list
- Enhanced issue update messages
- Quality check reminders

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-18 21:24:25 +02:00
parent 7a3d6ec26e
commit 8ac328e14f

View File

@@ -180,12 +180,19 @@ jobs:
- name: Check for changes - name: Check for changes
id: changes id: changes
run: | run: |
if git diff --quiet; then # Check both staged and unstaged changes
if git diff --quiet && git diff --cached --quiet; then
echo "has_changes=false" >> $GITHUB_OUTPUT echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No changes were made during implementation" echo "No changes were made during implementation"
else else
echo "has_changes=true" >> $GITHUB_OUTPUT echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Changes detected, preparing commit" echo "Changes detected, preparing commit"
# Show what changed for debugging
echo "=== Changed files ==="
git diff --name-only
git diff --cached --name-only
echo "===================="
fi fi
- name: Commit changes - name: Commit changes
@@ -217,67 +224,162 @@ jobs:
id: create-pr id: create-pr
with: with:
script: | script: |
const { data: pr } = await github.rest.pulls.create({ try {
owner: context.repo.owner, // Get the list of changed files for the PR description
repo: context.repo.repo, const { data: comparison } = await github.rest.repos.compareCommits({
title: `🤖 Implement: ${{ github.event.issue.title }}`, owner: context.repo.owner,
head: '${{ steps.create-branch.outputs.branch_name }}', repo: context.repo.repo,
base: 'dev', base: 'dev',
body: `## 🤖 Claude Implementation head: '${{ steps.create-branch.outputs.branch_name }}'
});
This PR was automatically created by Claude to implement the feature/fix requested in issue #${{ github.event.issue.number }}. const changedFiles = comparison.files || [];
const filesList = changedFiles.map(file => `- \`${file.filename}\``).join('\n');
### 📋 Issue Details const { data: pr } = await github.rest.pulls.create({
- **Issue**: #${{ github.event.issue.number }} owner: context.repo.owner,
- **Title**: ${{ github.event.issue.title }} repo: context.repo.repo,
- **Requested by**: @${{ github.event.comment.user.login }} title: `🤖 Implement: ${{ github.event.issue.title }}`,
- **Branch**: \`${{ steps.create-branch.outputs.branch_name }}\` head: '${{ steps.create-branch.outputs.branch_name }}',
base: 'dev',
body: `## 🤖 Claude Implementation
### 🔍 Implementation This PR was automatically created by Claude to implement the feature/fix requested in issue #${{ github.event.issue.number }}.
Claude analyzed the issue requirements and implemented the requested changes following the project's coding standards and best practices.
### ✅ Review Checklist ### 📋 Issue Details
- [ ] Code follows project conventions - **Issue**: #${{ github.event.issue.number }}
- [ ] Tests are included (if applicable) - **Title**: ${{ github.event.issue.title }}
- [ ] Documentation is updated (if needed) - **Requested by**: @${{ github.event.comment.user.login }}
- [ ] Implementation matches issue requirements - **Branch**: \`${{ steps.create-branch.outputs.branch_name }}\`
- [ ] No breaking changes (unless intended) - **Implementation Date**: ${new Date().toISOString()}
### 🔗 Related ### 📁 Files Changed
Closes #${{ github.event.issue.number }} ${filesList || 'No files were changed'}
--- ### 🔍 Implementation
Claude analyzed the issue requirements and implemented the requested changes following the project's coding standards and best practices.
**Note**: This implementation was generated automatically. Please review carefully before merging. ### ✅ Review Checklist
- [ ] Code follows project conventions
- [ ] Tests are included (if applicable)
- [ ] Documentation is updated (if needed)
- [ ] Implementation matches issue requirements
- [ ] No breaking changes (unless intended)
- [ ] Build passes (\`pnpm build\`)
- [ ] Type checking passes (\`pnpm typecheck\`)
- [ ] Linting passes (\`pnpm lint\`)
🤖 *Generated with Claude Automation*` ### 🔗 Related
}); Closes #${{ github.event.issue.number }}
return pr.number; ### 🚀 Deployment
After merging this PR:
1. Version will be automatically bumped
2. Package will be built and published
3. Changes will be available in the next release
---
**Note**: This implementation was generated automatically by Claude. Please review carefully before merging.
🤖 *Generated with [Claude Code](https://claude.ai/code)*
🔧 *Triggered by @${{ github.event.comment.user.login }}*`
});
console.log(`✅ PR created successfully: #${pr.number}`);
return pr.number;
} catch (error) {
console.error('Failed to create PR:', error);
throw error;
}
- name: Fallback PR Creation
if: steps.changes.outputs.has_changes == 'true' && failure() && steps.create-pr.conclusion == 'failure'
uses: actions/github-script@v7
id: fallback-pr
with:
script: |
console.log('Primary PR creation failed, attempting fallback...');
try {
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `🤖 Implement: ${{ github.event.issue.title }}`,
head: '${{ steps.create-branch.outputs.branch_name }}',
base: 'dev',
body: `## 🤖 Claude Implementation (Fallback)
This PR was automatically created by Claude to implement issue #${{ github.event.issue.number }}.
**Issue**: #${{ github.event.issue.number }} - ${{ github.event.issue.title }}
**Requested by**: @${{ github.event.comment.user.login }}
**Branch**: \`${{ steps.create-branch.outputs.branch_name }}\`
⚠️ *This PR was created via fallback method due to an error in the primary creation process.*
### 🔍 Implementation
Claude has implemented the requested changes. Please review the code changes in this PR.
### ✅ Review Required
- [ ] Verify implementation meets issue requirements
- [ ] Check code quality and conventions
- [ ] Test the changes
- [ ] Ensure no breaking changes
Closes #${{ github.event.issue.number }}
🤖 *Generated with Claude Automation*`
});
console.log(`✅ Fallback PR created successfully: #${pr.number}`);
return pr.number;
} catch (error) {
console.error('Fallback PR creation also failed:', error);
return null;
}
- name: Update issue with success - name: Update issue with success
if: steps.changes.outputs.has_changes == 'true' if: steps.changes.outputs.has_changes == 'true'
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
const prNumber = '${{ steps.create-pr.outputs.result }}' || '${{ steps.fallback-pr.outputs.result }}';
const prLink = prNumber ? `#${prNumber}` : 'Could not determine PR number';
await github.rest.issues.createComment({ await github.rest.issues.createComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: context.issue.number, issue_number: context.issue.number,
body: `✅ **Implementation Complete!** body: `✅ **Implementation Complete!**
I've successfully implemented the requested changes and created a pull request: I've successfully implemented the requested changes and created a pull request:
🎯 **Pull Request**: #${{ steps.create-pr.outputs.result }} 🎯 **Pull Request**: ${prLink}
🌿 **Branch**: \`${{ steps.create-branch.outputs.branch_name }}\` 🌿 **Branch**: \`${{ steps.create-branch.outputs.branch_name }}\`
⏱️ **Completed**: ${new Date().toISOString()} ⏱️ **Completed**: ${new Date().toISOString()}
🔧 **Triggered by**: @${{ github.event.comment.user.login }}
## Next Steps ## 📋 What Was Done
1. Review the implementation in the pull request - ✅ Analyzed issue requirements
2. Test the changes locally if needed - ✅ Implemented requested features/fixes
3. Merge the PR if everything looks good - ✅ Followed project coding standards
- ✅ Created pull request for review
- ✅ Applied proper branch naming (\`claude/issue-${{ github.event.issue.number }}-*\`)
The implementation follows the project's coding standards and includes appropriate documentation.` ## 🔍 Next Steps
1. **Review** the implementation in the pull request
2. **Test** the changes locally if needed
3. **Check** that build/typecheck/lint passes
4. **Merge** the PR if everything looks good
## 🛠️ Quality Checks
The implementation includes:
- TypeScript with proper typing
- ESM module structure with .js extensions
- Following existing code patterns
- Appropriate documentation updates
**Ready for review!** 🚀`
}); });
- name: Update issue with no changes - name: Update issue with no changes