@@ -23,51 +23,36 @@ jobs:
23
23
pipx install poetry
24
24
poetry install --all-extras
25
25
26
- - name : Check if README.md was modified directly
26
+ - name : Check for README changes
27
27
id : check_changes
28
28
run : |
29
29
# Get the list of changed files in the last commit
30
30
CHANGED_FILES=$(git diff --name-only HEAD^)
31
31
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
35
41
else
36
- echo "readme_only_change =false" >> $GITHUB_OUTPUT
42
+ echo "readme_py_changed =false" >> $GITHUB_OUTPUT
37
43
fi
38
44
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'
41
47
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
46
49
poetry run ./make_readme.sh
47
50
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
56
58
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