openrag/.github/workflows/autofix.yml
Edwin Jose b9d1272234 Add autofix workflow for Python code
Introduces a GitHub Actions workflow that runs on pushes to main and manual dispatch. The workflow syncs dependencies with uv, runs ruff for linting and formatting, and commits any fixes automatically.
2025-12-05 20:30:48 -05:00

64 lines
1.5 KiB
YAML

name: Autofix (uv sync, ruff check & format)
on:
push:
branches:
- main
paths:
- 'pyproject.toml'
- '**/*.py'
workflow_dispatch:
jobs:
autofix:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Sync dependencies and update uv.lock
run: uv sync
- name: Install ruff
run: uv pip install ruff
- name: Run ruff check with fixes
run: ruff check --fix .
continue-on-error: true
- name: Run ruff format
run: ruff format .
- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "No changes detected"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "Changes detected:"
git diff --stat
fi
- name: Commit and push changes
if: steps.changes.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "chore: autofix - uv sync, ruff check & format [skip ci]"
git push