From 7223b379e76bc45d10a6d14edcaeefdea5590c05 Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sun, 22 Dec 2024 13:36:26 +0100 Subject: [PATCH] Introduces pre-commit github-action https://github.com/Stirling-Tools/Stirling-PDF/blob/main/.pre-commit-config.yaml --- .github/workflows/pre_commit.yml | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/pre_commit.yml diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml new file mode 100644 index 00000000..b8948ded --- /dev/null +++ b/.github/workflows/pre_commit.yml @@ -0,0 +1,55 @@ +name: Pre-commit + +on: + push: + branches: [main] + +permissions: read-all + +jobs: + update: + if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Set up git config + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + - name: Install Dependencies + run: | + pip install pre-commit==4.0.1 + - name: Run pre-commit and git add + run: | + pre-commit run -c .pre-commit-config.yaml || true + git add . + git diff --staged --quiet || git commit -m ":file_folder: pre-commit + > Made via .github/workflows/pre_commit.yml" || echo "pre-commit: no changes" + - name: Create Pull Request + uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update files + committer: GitHub Action + author: GitHub Action + signoff: true + branch: pre-commit + title: "🔨 [pre-commit] Update files by " + body: | + Auto-generated by [create-pull-request][1] + + [1]: https://github.com/peter-evans/create-pull-request + draft: false + delete-branch: true + labels: github-actions + sign-commits: true