From 4ce6323ad0c4b69d7a167cdef4eb3c56bf47ff45 Mon Sep 17 00:00:00 2001
From: Bilal Kahraman <kahramannbilal@gmail.com>
Date: Mon, 26 Aug 2024 23:34:17 +0300
Subject: [PATCH] Add linter

---
 .github/workflows/lint.yaml | 39 +++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 .github/workflows/lint.yaml

diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
new file mode 100644
index 0000000..3ee982d
--- /dev/null
+++ b/.github/workflows/lint.yaml
@@ -0,0 +1,39 @@
+name: Linter
+
+on:
+  pull_request:
+    branches: [ "master" ]
+    types: [opened, labeled, unlabeled, synchronize]
+jobs:
+  format-code:
+    runs-on: ubuntu-latest
+
+    permissions:
+      # Give the default GITHUB_TOKEN write permission to commit and push the
+      # added or changed files to the repository.
+      contents: write
+    
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          token: ${{ secrets.BOT_TOKEN || github.token }}
+          # check out HEAD on the branch
+          ref: ${{ github.head_ref }}
+          # make sure the parent commit is grabbed as well, because
+          # that's what will get formatted (i.e. the most recent commit)
+          fetch-depth: 2
+      - name: Install clang-format
+        run: |
+          sudo apt-get install -y clang-format
+      - name: Run clang-format
+        run: |
+          # run clang-format on all files in the repo
+          # (except for the .git and .vscode directory) and use .clang-format
+          # as the style guide
+          find . \( -path ./.git -prune -o -path ./third-party -prune -path ./assets -prune \) -name "*.cpp" -o -name "*.h" | xargs clang-format -i -style=file
+      # commit the changes (if there are any)
+      - name: Commit changes
+        uses: stefanzweifel/git-auto-commit-action@v5
+        with:
+          commit_message: 🎨 apply clang-format changes
+          branch: ${{ github.head_ref }}
\ No newline at end of file