Skip to content

Commit

Permalink
ci: Add formatter to run on all pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
holtskinner committed Dec 6, 2024
1 parent cefb94a commit e281f1a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Run Formatting on Pull Requests

on:
pull_request:
branches:
- "**" # Runs on all branches

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip nox
- name: Run Nox Format
run: nox -s format

- name: Check for uncommitted changes
id: git_diff
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes_detected=true" >> $GITHUB_ENV
else
echo "changes_detected=false" >> $GITHUB_ENV
fi
- name: Commit and push changes
if: env.changes_detected == 'true'
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "Run nox format"
git push

0 comments on commit e281f1a

Please sign in to comment.