diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..aa35b9e --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,44 @@ +name: Pre-commit and Auto Merge + +on: + push: + branches: + - '**' # This will trigger on pushes to any branch + pull_request: + branches: + - '**' # This will trigger on PRs to any branch + +jobs: + pre-commit: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' # Set the version you need + + - name: Install pre-commit + run: pip install pre-commit + + - name: Run pre-commit + run: | + pre-commit run --all-files + git config --global user.name "GitHub Action" + git config --global user.email "action@github.com" + git add . + + - name: Commit changes + run: git commit -m "Apply pre-commit changes" || echo "No changes to commit" + + - name: Merge changes + run: | + # Check if there are changes to push + if [ -n "$(git status --porcelain)" ]; then + git push origin "${{ github.ref }}" + else + echo "No changes to push." + fi