From 0e7317dec6ea4d98aecc373f3df1a05efaba0eea Mon Sep 17 00:00:00 2001 From: OreoNoCake <146687855+NTGNguyen@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:09:31 +0700 Subject: [PATCH] Create precommit.yml --- .github/workflows/precommit.yml | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/precommit.yml diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 0000000..e79ec0c --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,46 @@ +name: Pre-commit Auto Fix + +on: + push: + branches: + - main + +jobs: + pre-commit: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.12" + + - name: Install dependencies + if: ${{ always() }} + run: | + python -m pip install --upgrade pip + pip install pre-commit + + - name: Run pre-commit + if: ${{ always() }} + run: pre-commit run --all-files + + - name: Create Pull Request + if: ${{ always() }} + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "🎨 Auto Code Fix (Pre-commit)" + branch: auto/pre-commit-fix + title: "🎨 Auto Code Fix (Pre-commit)" + body: "This pull request contains auto code fixes from pre-commit." + labels: | + auto-fix + pre-commit