-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This is a format job. Pre-commit has a first-party GitHub action, so we use | ||
# that: https://github.com/pre-commit/action | ||
|
||
name: PR fix formatting | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
pre-commit: | ||
name: Format | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # fetch all history for all branches and tags, which might be needed when pushing commits. | ||
token: ${{ secrets.BOT_PAT }} | ||
ref: ${{ github.head_ref }} | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.10.6 | ||
- name: Install system hooks | ||
run: sudo apt update && sudo apt install -qq clang-format-14 cppcheck | ||
- name: Run pre-commit checks | ||
uses: pre-commit/action@v3.0.1 | ||
with: | ||
extra_args: --all-files --hook-stage manual | ||
continue-on-error: true | ||
- name: Commit and push if changed | ||
run: | | ||
git diff | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
git add -u | ||
git commit -m "Automated code fixes by pre-commit." || echo "No changes to commit" | ||
git push origin HEAD:${{ github.head_ref }} |