@@ -23,51 +23,36 @@ jobs:
2323 pipx install poetry
2424 poetry install --all-extras
2525
26- - name : Check if README.md was modified directly
26+ - name : Check for README changes
2727 id : check_changes
2828 run : |
2929 # Get the list of changed files in the last commit
3030 CHANGED_FILES=$(git diff --name-only HEAD^)
3131
32- # Check if README.md was the only file changed
33- if [[ $(echo "$CHANGED_FILES" | grep -v "README.md" | wc -l) -eq 0 ]]; then
34- echo "readme_only_change=true" >> $GITHUB_OUTPUT
32+ # Check if README.md was modified
33+ if echo "$CHANGED_FILES" | grep -q "README.md"; then
34+ echo "Error: README.md was modified directly. This file is auto-generated from README.py. Please modify README.py instead."
35+ exit 1
36+ fi
37+
38+ # Check if README.py was modified
39+ if echo "$CHANGED_FILES" | grep -q "README.py"; then
40+ echo "readme_py_changed=true" >> $GITHUB_OUTPUT
3541 else
36- echo "readme_only_change =false" >> $GITHUB_OUTPUT
42+ echo "readme_py_changed =false" >> $GITHUB_OUTPUT
3743 fi
3844
39- - name : Convert README.md to README.py
40- if : steps.check_changes.outputs.readme_only_change == 'true'
45+ - name : Update README.md from README.py
46+ if : steps.check_changes.outputs.readme_py_changed == 'true'
4147 run : |
42- # Save current README.md
43- cp README.md README.md.orig
44-
45- # Run make_readme.sh to get a clean README.md
48+ # Run make_readme.sh to update README.md from README.py
4649 poetry run ./make_readme.sh
4750
48- # Restore original README.md
49- mv README.md.orig README.md
50-
51- # Check if there are differences in README.py
52- if ! git diff --quiet README.py; then
53- echo "changes_detected=true" >> $GITHUB_OUTPUT
54- else
55- echo "changes_detected=false" >> $GITHUB_OUTPUT
51+ # Commit and push if there are changes
52+ if ! git diff --quiet README.md; then
53+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
54+ git config --local user.name "github-actions[bot]"
55+ git add README.md
56+ git commit -m "[auto] Sync README.md"
57+ git push
5658 fi
57-
58- - name : Create Pull Request
59- if : steps.check_changes.outputs.readme_only_change == 'true' && steps.check_changes.outputs.changes_detected == 'true'
60- uses : peter-evans/create-pull-request@v5
61- with :
62- commit-message : " [auto] Sync README.md"
63- title : " docs: Sync README changes"
64- body : |
65- This PR was automatically created because README.md was edited directly.
66-
67- In this project, we maintain README.md through README.py to ensure proper formatting and consistency.
68- Please make future edits to README.py instead of README.md.
69-
70- This PR updates README.py to match the changes made to README.md.
71- branch : fix/readme-sync
72- delete-branch : true
73- labels : documentation
0 commit comments