Skip to content

Conversation

@hobbytp
Copy link
Owner

@hobbytp hobbytp commented Nov 13, 2025

🚀 Summary

This PR introduces automatic AI cover generation for new blog articles, making the blog content creation workflow completely hands-free. When new articles are committed to the main branch, AI covers are automatically generated using the ModelScope Qwen-image API.

✨ Key Features

🆕 Automatic Generation (Push Trigger)

  • Zero-touch workflow: Simply commit new articles and AI covers are generated automatically
  • Smart detection: Only processes articles with description but missing ai_cover
  • API protection: Limits to 5 files per push to avoid overload
  • Excludes daily AI news: Skips daily_ai/ directory to prevent redundant processing

🧠 Enhanced Workflow

  • Push trigger: New .github/workflows/generate-blog-images.yml with intelligent file filtering
  • Manual trigger: Still supports manual generation via Actions tab
  • Dual service support: ModelScope (default) + Gemini compatibility
  • Progress tracking: Real-time generation status and detailed reports

🔧 Technical Improvements

  • Fixed front matter parsing: Resolved YAML parsing issues with Chinese/English quotes
  • Enhanced script: scripts/ai_cover_generator.py with --specific-file support
  • Better error handling: Improved logging and exception management
  • Optimized caching: Smart content hash-based duplicate prevention

📊 Files Changed

  • Core Workflow: .github/workflows/generate-blog-images.yml - Enhanced with push trigger
  • AI Generator: scripts/ai_cover_generator.py - New automatic generation capabilities
  • Documentation: Comprehensive guides and integration reports
  • Generated Covers: 17 high-quality AI-generated covers included

🎯 Usage Examples

Automatic (Recommended)

# Simply commit new articles - AI covers generated automatically
git add content/zh/category/new-article.md
git commit -m "Add new article"
git push origin main

Manual Generation

# Generate AI covers manually (for existing articles)
make generate-ai-covers

# GitHub Actions interface
# Visit Actions → "Generate Blog Images" → Run workflow

🧪 Testing

  • Manual testing: Successfully generated covers for specific files
  • Workflow testing: Push trigger detection works correctly
  • API integration: ModelScope Qwen-image API functioning properly
  • File updates: Front matter correctly updated with AI cover metadata

📈 Impact

  • 17 new AI covers: High-quality covers automatically generated for existing articles
  • Zero manual effort: New articles get AI covers without any manual steps
  • API efficiency: Smart limiting prevents API overload and cost issues
  • Backward compatibility: Existing functionality preserved

🔒 Security & Performance

  • API key management: Secure storage using GitHub Secrets
  • Rate limiting: Built-in protection against API abuse
  • Error handling: Robust exception handling and retry mechanisms
  • Resource optimization: Efficient file processing and caching

📚 Documentation

  • Integration guide: docs/modelscope-github-workflow-integration.md
  • Technical details: docs/modelscope-ai-cover-integration.md
  • Change proposal: docs/change-proposals/2025-11-12-add-modelscope-ai-cover-generation.md
  • Usage instructions: Updated CLAUDE.md with new commands

🎉 Result

The blog now has fully automated AI cover generation. Content creators can focus on writing while the system handles visual content automatically. This represents a significant improvement in content creation efficiency and quality.

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

hobbytp and others added 18 commits November 13, 2025 08:19
- 🚀 NEW: Automatic AI cover generation on push to main branch
- 🧠 Smart detection: Only generates covers for articles with description but no AI cover
- 🛡️ API protection: Limits processing to 5 files per push to avoid overload
- 📝 Enhanced workflow: Added push trigger with intelligent file filtering
- 🔧 Script improvements: Fixed front matter parsing, added --specific-file support
- 📚 Updated documentation: Comprehensive guides and integration reports
- 🎨 Generated covers: Added 17 high-quality AI-generated covers

This enables zero-touch AI cover generation - simply commit new articles and
AI covers are automatically generated using ModelScope Qwen-image API.

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
- Change git push from main to HEAD to work with feature branches
- Fixes 'src refspec main does not match any' error
- Ensures image optimization works on all branches

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
- Change from 'HEAD' to '${{ github.ref_name }}' for proper Git reference
- Fixes 'not a full refname' error
- Ensures push works correctly with feature branches
- Uses GitHub Actions built-in ref_name variable

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
- Implement smart branching logic for different scenarios:
  * main branch: git push origin main
  * pull request: git push origin HEAD:${{ github.ref }}
  * feature branches: git push origin HEAD:${{ github.ref_name }}
- Fixes refname issues with GitHub Actions context
- Handles both push and pull_request events properly
- Ensures compatibility across different branch types

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
- Fix PR branch detection using GitHub API
- Use jq to extract source branch from PR data
- Install jq dependency for JSON parsing
- Push to source branch instead of PR merge ref
- Handle case where source branch cannot be determined

Resolves 'deny updating a hidden ref' error for pull_request events.

🤖 Generated with Claude Code

Co-Authored-By: Claude <[email protected]>
生成多尺寸图片 (320px, 640px, 960px, 1280px, 1920px)

转换为WebP格式以减少文件大小

应用智能压缩 (质量: 85%)

此提交由GitHub Actions自动生成
生成多尺寸图片 (320px, 640px, 960px, 1280px, 1920px)

转换为WebP格式以减少文件大小

应用智能压缩 (质量: 85%)

此提交由GitHub Actions自动生成
生成多尺寸图片 (320px, 640px, 960px, 1280px, 1920px)

转换为WebP格式以减少文件大小

应用智能压缩 (质量: 85%)

此提交由GitHub Actions自动生成
生成多尺寸图片 (320px, 640px, 960px, 1280px, 1920px)

转换为WebP格式以减少文件大小

应用智能压缩 (质量: 85%)

此提交由GitHub Actions自动生成
生成多尺寸图片 (320px, 640px, 960px, 1280px, 1920px)

转换为WebP格式以减少文件大小

应用智能压缩 (质量: 85%)

此提交由GitHub Actions自动生成
生成多尺寸图片 (320px, 640px, 960px, 1280px, 1920px)

转换为WebP格式以减少文件大小

应用智能压缩 (质量: 85%)

此提交由GitHub Actions自动生成
@hobbytp hobbytp merged commit f00923e into main Nov 13, 2025
1 check 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.

3 participants