@@ -2,11 +2,13 @@ name: README Sync
2
2
3
3
on :
4
4
push :
5
+ paths :
6
+ - ' README.py'
5
7
6
8
jobs :
7
- sync -readme :
9
+ create -readme-pr :
8
10
runs-on : ubuntu-latest
9
- if : ${{ !contains( github.event.head_commit.message, '[auto] Sync README.md') }}
11
+ if : ${{ github.actor != 'github-actions[bot]' }}
10
12
11
13
steps :
12
14
- uses : actions/checkout@v4
@@ -23,36 +25,30 @@ jobs:
23
25
pipx install poetry
24
26
poetry install --all-extras
25
27
26
- - name : Check for README changes
27
- id : check_changes
28
+ - name : Create branch and update README
28
29
run : |
29
- # Get the list of changed files in the last commit
30
- CHANGED_FILES=$( git diff --name-only HEAD^)
30
+ # Create new branch
31
+ git checkout -b readme-sync-${{ github.sha }}
31
32
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
41
- else
42
- echo "readme_py_changed=false" >> $GITHUB_OUTPUT
43
- fi
44
-
45
- - name : Update README.md from README.py
46
- if : steps.check_changes.outputs.readme_py_changed == 'true'
47
- run : |
48
- # Run make_readme.sh to update README.md from README.py
33
+ # Generate new README.md
49
34
poetry run ./make_readme.sh
50
35
51
- # Commit and push if there are changes
36
+ # Setup git
37
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
38
+ git config --local user.name "github-actions[bot]"
39
+
40
+ # Commit changes if README.md was modified
52
41
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
42
git add README.md
56
43
git commit -m "[auto] Sync README.md"
57
- git push
44
+ git push origin readme-sync-${{ github.sha }}
58
45
fi
46
+
47
+ - name : Create Pull Request
48
+ uses : peter-evans/create-pull-request@v7
49
+ with :
50
+ title : ' [auto] Sync README.md from README.py'
51
+ body : ' Auto-generated PR to sync README.md with changes from README.py'
52
+ branch : readme-sync-${{ github.sha }}
53
+ base : ${{ github.ref }}
54
+ labels : automated,documentation
0 commit comments