Skip to content

Generate Recipe JSON #10

Generate Recipe JSON

Generate Recipe JSON #10

name: Generate Recipe JSON
on:
push:
branches: [ main, master ]
paths:
- 'dishes/**/*.md'
pull_request:
branches: [ main, master ]
paths:
- 'dishes/**/*.md'
workflow_dispatch: # 允许手动触发
jobs:
generate-json:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整历史记录以支持统计比较
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Generate recipes JSON
run: python scripts/generate_recipes.py
- name: Check for changes
id: changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "Detected changes:"
git status --short
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
- name: Commit and push if changed
if: steps.changes.outputs.changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add all_recipes.json
git add recipe_stats.json
git add CHANGELOG.md
git commit -m "Auto-update recipes JSON and changelog
- Updated all_recipes.json with latest recipe data
- Updated changelog with recipe count changes
- Generated by GitHub Actions
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>"
git push