From 344645d7047d8185de93b9e26c52642f0aa6a9f5 Mon Sep 17 00:00:00 2001 From: Anurag Kumar Singh Date: Mon, 11 May 2026 11:42:00 +0530 Subject: [PATCH] Added Github-Action to autoformat code with stylua upon PR merge --- .github/workflows/stylua.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/stylua.yml diff --git a/.github/workflows/stylua.yml b/.github/workflows/stylua.yml new file mode 100644 index 0000000..b90fa3a --- /dev/null +++ b/.github/workflows/stylua.yml @@ -0,0 +1,50 @@ +name: Auto Format Lua + +on: + pull_request: + types: [opened, synchronize] + +permissions: + contents: write + +jobs: + stylua: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check formatting + id: check + uses: JohnnyMorganz/stylua-action@v4 + continue-on-error: true + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . + + - name: Format Lua files + if: steps.check.outcome == 'failure' + uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: . + + - name: Commit changes + if: steps.check.outcome == 'failure' + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + git add . + + git diff --cached --quiet || \ + git commit -m "style: auto format lua" + + - name: Push changes + if: steps.check.outcome == 'failure' + run: git push