Format Code via Ruff #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Format Code via Ruff | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: 'Branch to format' | |
| required: true | |
| default: 'master' | |
| type: string | |
| jobs: | |
| code-format: | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.branch }} | |
| - name: Set up Python3 | |
| uses: actions/setup-python@v4 | |
| - name: Install Ruff Linter | |
| run: pip install ruff | |
| - name: Run Ruff to Format Code | |
| run: | | |
| ruff check . --exit-zero | |
| ruff format . | |
| git add -u | |
| - name: Commit and Push Changes | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| if git diff-index --quiet HEAD --; then | |
| echo "No changes to commit." | |
| else | |
| git commit -m "style: Auto Ruff Formatter" | |
| git push origin HEAD:${{ github.event.inputs.branch }} | |
| fi |