Skip to content

Commit

Permalink
add auto format PR
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Dec 30, 2024
1 parent 1625f5d commit 1ceb0a7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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: [email protected]
message: Automated code formatting
push: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 1ceb0a7

Please sign in to comment.