Skip to content

Commit

Permalink
Update Code-Formatter.yml
Browse files Browse the repository at this point in the history
Push changes if detected
  • Loading branch information
Tams3d authored Nov 29, 2024
1 parent c3a989e commit a1e05b6
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/Code-Formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,20 @@ jobs:
- name: Format code with Black
uses: psf/black@stable
with:
options: "." # Options for Black (e.g., --line-length)
src: "." # The directory to format (entire repo)
options: "."
src: "."

- name: Check for changes
id: check_changes
run: |
# Check if there are code changes after formatting
git diff --exit-code || echo "Code changes detected"
continue-on-error: true

- name: Commit formatted code
if: steps.check_changes.outputs.exit_code != '0'
run: |
# Configure Git user
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
# Add and commit changes if any
git add .
git diff --quiet && git diff --staged --quiet || git commit -m "Format code with Black"
Expand All @@ -49,10 +45,7 @@ jobs:
- name: Display changes and success message
if: steps.check_changes.outputs.exit_code != '0'
run: |
# Show a summary of the changes made by Black
echo "The code has been successfully formatted with Black."
echo "The following changes were made:"
git diff --name-only HEAD~1 HEAD
# Display success message
echo "Code formatting completed successfully and changes have been pushed."

0 comments on commit a1e05b6

Please sign in to comment.