From 1ceb0a7c34d6adf7700a56013373a1a4c7bf49c7 Mon Sep 17 00:00:00 2001 From: Liam Teale Date: Sun, 29 Dec 2024 17:07:52 -0800 Subject: [PATCH] add auto format PR --- .github/workflows/auto-format.yml | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/auto-format.yml diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml new file mode 100644 index 0000000..03ad811 --- /dev/null +++ b/.github/workflows/auto-format.yml @@ -0,0 +1,38 @@ +# automatically format code using clang-format when a pull request is merged or manually triggered +name: format-code + +on: + pull_request: + types: [closed] # on merge pull request + workflow_dispatch: # allows manual triggering + +permissions: + contents: write + +jobs: + format: + if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Format code # Outputs the correctly formatted code + uses: DoozyX/clang-format-lint-action@v0.18 + with: + source: './src/lemlib ./include/lemlib' + extensions: 'hpp,cpp' + clangFormatVersion: 18 + inplace: true # Same as `clang-format -i` + + # Commits the correctly formatted files to the repository + - name: Commit changes + uses: EndBug/add-and-commit@v9 + with: + author_name: GitHub Action + author_email: action@github.com + message: Automated code formatting + push: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file