Skip to content

Commit

Permalink
ci: Add formatter to run on all pull requests (#1488)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtskinner authored Dec 6, 2024
1 parent cefb94a commit 142ae23
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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

# Ensure the pull request branch is checked out
with:
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 142ae23

Please sign in to comment.