wrongmove/.github/workflows/ruff.yml
2025-09-14 19:40:18 +01:00

39 lines
1.3 KiB
YAML

name: Run Ruff and Auto-merge
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
ruff-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch all history for diffing
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11' # Or your desired Python version
- name: Install Ruff
run: pip install ruff
- name: Get changed files
id: changed_files
run: |
# Get a list of changed files between the base and head commits of the PR
git diff --name-only --diff-filter=d ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > changed_files.txt
# Filter for Python files
grep -E '\.py$' changed_files.txt > python_files.txt
# Remove newlines and join with spaces
echo "files=$(tr '\n' ' ' < python_files.txt)" >> $GITHUB_OUTPUT
- name: Run Ruff on changed files
if: steps.changed_files.outputs.files != ''
run: |
# The ruff command will only run if there are Python files to check
ruff check ${{ steps.changed_files.outputs.files }}