Skip to content

Commit aafe4f5

Browse files
committed
Open PR instead of adding commit
1 parent db03730 commit aafe4f5

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

.github/workflows/readme-sync.yml

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ name: README Sync
22

33
on:
44
push:
5+
paths:
6+
- 'README.py'
57

68
jobs:
7-
sync-readme:
9+
create-readme-pr:
810
runs-on: ubuntu-latest
9-
if: ${{ !contains(github.event.head_commit.message, '[auto] Sync README.md') }}
11+
if: ${{ github.actor != 'github-actions[bot]' }}
1012

1113
steps:
1214
- uses: actions/checkout@v4
@@ -23,36 +25,30 @@ jobs:
2325
pipx install poetry
2426
poetry install --all-extras
2527
26-
- name: Check for README changes
27-
id: check_changes
28+
- name: Create branch and update README
2829
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 }}
3132
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
4934
poetry run ./make_readme.sh
5035
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
5241
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]"
5542
git add README.md
5643
git commit -m "[auto] Sync README.md"
57-
git push
44+
git push origin readme-sync-${{ github.sha }}
5845
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

Comments
 (0)