Skip to content

Commit b9e8454

Browse files
authored
Verify changes before commit in changelog-pr.yml (#310)
1 parent d4ae7a9 commit b9e8454

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

.github/workflows/changelog-pr.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,6 @@ jobs:
3737
echo "LATEST_DATE=$LATEST_DATE" >> $GITHUB_ENV
3838
fi
3939
40-
- name: Check if CHANGELOG.md was modified
41-
id: changelog-check
42-
run: |
43-
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
44-
echo "Changed files: $CHANGED_FILES"
45-
if echo "$CHANGED_FILES" | grep -q 'CHANGELOG.md'; then
46-
echo "Changes detected in CHANGELOG.md, skipping additional checks."
47-
echo "changelog_modified=true" >> $GITHUB_ENV
48-
else
49-
echo "No changes to CHANGELOG.md, continuing with protection checks."
50-
echo "changelog_modified=false" >> $GITHUB_ENV
51-
fi
52-
5340
- name: Get categorized pull requests
5441
id: get-categorized-prs
5542
uses: actions/github-script@v7
@@ -123,9 +110,14 @@ jobs:
123110
124111
const newChangelogContent = changelogContent.replace(regex, newReleaseNotes)
125112
await fs.writeFile(changelogPath, newChangelogContent);
126-
113+
114+
- name: Check if there are any changes
115+
id: verify-diff
116+
run: |
117+
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
127118
128119
- name: Commit and push changes to separate branch
120+
if: steps.verify-diff.outputs.changed == 'true'
129121
run: |
130122
git config --global user.name "github-actions[bot]"
131123
git config --global user.email "github-actions[bot]@users.noreply.github.com"
@@ -135,6 +127,7 @@ jobs:
135127
git push origin $BRANCH_NAME --force
136128
137129
- name: Create pull request if not exists
130+
if: steps.verify-diff.outputs.changed == 'true'
138131
env:
139132
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140133
run: |

0 commit comments

Comments
 (0)