Skip to content

Commit

Permalink
Apply black and isort formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
fvergaracl committed Feb 7, 2024
1 parent 4183b66 commit c465263
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Apply black & isort
name: Format Python code

on:
push:
Expand All @@ -8,25 +8,37 @@ on:
jobs:
format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
ref: ${{ github.head_ref }}
- name: black and isort
python-version: "3.10.9"
- name: Install black and isort
run: |
pip install black isort
- name: Run black
run: |
black . -l 120
- name: Run isort
run: |
isort . -l 120 --profile black
- name: Check for modified files
id: git-check
run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_ENV
run: |
echo "modified=$(if git diff-index --quiet HEAD --; then echo 'false'; else echo 'true'; fi)" >> $GITHUB_ENV
- name: Push changes
- name: Commit changes
if: env.modified == 'true'
run: |
git config --global user.name '${{ secrets.MY_GITHUB_USER }}'
git config --global user.email '${{ secrets.MY_GITHUB_EMAIL }}'
git config --global user.name 'github-actions'
git config --global user.email 'noreply@github.com'
git add .
git commit -m "Apply black & isort"
git commit -m "Apply black and isort formatting"
git push

0 comments on commit c465263

Please sign in to comment.