@@ -31,15 +31,30 @@ jobs:
3131 changed_files=$(git diff --name-only HEAD~1 HEAD | grep -E '\.(js|json|css|html)$' || true)
3232
3333 if [[ -n "$changed_files" ]]; then
34+ echo "Found changed files to format:"
35+ echo "$changed_files"
36+
37+ # Run prettier on the changed files
3438 echo "$changed_files" | xargs prettier --write --print-width 200
35-
36- echo "changed=true" >> "$GITHUB_OUTPUT"
39+
40+ # Check if prettier actually made any changes
41+ if git diff --quiet && git diff --cached --quiet; then
42+ echo "No formatting changes were made by Prettier"
43+ echo "prettier_changes=false" >> "$GITHUB_OUTPUT"
44+ else
45+ echo "Prettier made formatting changes"
46+ echo "prettier_changes=true" >> "$GITHUB_OUTPUT"
47+ fi
48+
49+ echo "prose_changes=true" >> "$GITHUB_OUTPUT"
3750 else
38- echo "changed=false" >> "$GITHUB_OUTPUT"
51+ echo "No JavaScript, JSON, CSS, or HTML files were changed in this commit."
52+ echo "prose_changes=false" >> "$GITHUB_OUTPUT"
53+ exit 0
3954 fi
4055
4156 - name : Commit and push changes
42- if : steps.run_prettier.outputs.changed == 'true'
57+ if : steps.run_prettier.outputs.prettier_changes == 'true'
4358 run : |
4459 git config --local user.name "github-actions[bot]"
4560 git config --local user.email "github-actions[bot]@users.noreply.github.com"
4964
5065 # Push to the main branch using PAT
5166 git push origin HEAD:${{ github.ref_name }}
52-
53- - name : No changes to commit
54- if : steps.run_prettier.outputs.changed == 'false'
55- run : echo "No changes to commit."
67+ echo "Changes committed and pushed successfully"
0 commit comments