Skip to content

Auto format code on non-protected branches. #4

Auto format code on non-protected branches.

Auto format code on non-protected branches. #4

Workflow file for this run

name: Automaticallly format the code with ruff
on:
pull_request:
branches:
- 'main'
paths:
- '**.py'
jobs:
ruff:
permissions:
contents: write
pull-requests: write
name: Format the code with ruff and push the changes
runs-on: ubuntu-latest
env:
GIT_COMMIT_MESSAGE: |
Format with ruff
See https://icalendar.readthedocs.io/en/stable/contribute/development.html#code-format
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.14
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install . --group formatting
- name: Format the code with ruff
run: ruff format
- name: Format the code with ruff check
run: ruff check --fix
- name: Show the changes
run: |
git status
git diff
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -a -m "${GIT_COMMIT_MESSAGE}" || echo "No changes to commit"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}