diff --git a/.github/workflows/pre-commit-autoupdate.yaml b/.github/workflows/pre-commit-autoupdate.yaml new file mode 100644 index 0000000..929494f --- /dev/null +++ b/.github/workflows/pre-commit-autoupdate.yaml @@ -0,0 +1,49 @@ +# based on https://github.com/cookiecutter/cookiecutter-django/blob/master/ +# .github/workflows/pre-commit-autoupdate.yml +# run pre-commit autoupdate and create a pull request if any changes + +name: pre-commit auto-update + +on: + schedule: + - cron: "0 6 * * 1" # every Monday at 06:00 UTC + workflow_dispatch: # to trigger manually + +permissions: + contents: read + +jobs: + auto-update: + # disables this workflow from running in a repository that is not part of + # the indicated organization/user + if: github.repository_owner == 'martibosch' + permissions: + contents: write # for peter-evans/create-pull-request to create branch + pull-requests: write # for peter-evans/create-pull-request to create PR + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: install pre-commit + run: pip install pre-commit + + - name: autoupdate template + run: pre-commit autoupdate + + - name: autoupdate generated projects + working-directory: "{{ cookiecutter.repo_name }}" + run: pre-commit autoupdate + + - name: create pull request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: update/pre-commit-autoupdate + title: auto-update pre-commit hooks + commit-message: "build: auto-update pre-commit hooks" + body: update to latest versions in pre-commit configs + labels: update