diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml deleted file mode 100644 index 70916ec9..00000000 --- a/.github/workflows/pre-commit-autoupdate.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Autoupdate pre-commit hooks - -on: - schedule: - # Every day at 4 am UTC - - cron: 0 4 * * * - -jobs: - pre-commit-autoupdate: - if: ${{ github.repository == 'digikwal/frappe_docker' }} - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v4 - - - name: Cache pre-commit environment - uses: actions/cache@v4 - with: - path: | - ~/.cache/pre-commit - ~/.cache/pip - key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - restore-keys: | - ${{ runner.os }}-pre-commit- - - - name: Install pre-commit - run: pip install -U pre-commit - - - name: Update pre-commit hooks - run: pre-commit autoupdate --color=always - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 - with: - branch: pre-commit-autoupdate - title: "chore(deps): Update pre-commit hooks" - commit-message: "chore(deps): Update pre-commit hooks" - body: Update pre-commit hooks - labels: dependencies,development - delete-branch: true diff --git a/.github/workflows/update-hooks.yml b/.github/workflows/update-hooks.yml new file mode 100644 index 00000000..eb392a78 --- /dev/null +++ b/.github/workflows/update-hooks.yml @@ -0,0 +1,66 @@ +name: Update pre-commit hooks + +on: + schedule: + - cron: '0 4 * * 0' + workflow_dispatch: {} + +permissions: + contents: write + pull-requests: write + +jobs: + pre-commit-autoupdate: + if: ${{ github.repository == 'digikwal/frappe_docker' }} + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - name: Cache pre-commit environment + uses: actions/cache@v4 + with: + path: | + ~/.cache/pre-commit + ~/.cache/pip + key: pre-commit-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }} + restore-keys: | + pre-commit-${{ runner.os }}- + + - name: Install pre-commit + run: pip install --upgrade pre-commit + + - name: Autoupdate pre-commit hooks + run: pre-commit autoupdate --color=always + + - name: Clean up unused environments (optional) + run: pre-commit gc + + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v7 + with: + branch: pre-commit-autoupdate-${{ github.run_id }} + title: "chore(deps): update pre-commit hooks ($(date +'%Y-%m-%d'))" + commit-message: "chore(deps): update pre-commit hooks ($(date +'%Y-%m-%d'))" + body: | + This PR updates pre-commit hooks to their latest versions. + _Generated automatically by GitHub Actions._ + labels: dependencies,development + delete-branch: true + draft: false + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable Auto-Merge + if: steps.cpr.outputs.pull-request-number != '' + uses: peter-evans/enable-pull-request-automerge@v3 + with: + pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} + merge-method: squash + token: ${{ secrets.GITHUB_TOKEN }}