|
| 1 | +# Copyright (c) 2023 Sebastian Pipping <[email protected]> |
| 2 | +# Licensed under the MIT license |
| 3 | + |
| 4 | +name: Detect outdated pre-commit hooks |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + - cron: '0 16 * * 5' # Every Friday 4pm |
| 9 | + |
| 10 | +# NOTE: This will drop all permissions from GITHUB_TOKEN except metadata read, |
| 11 | +# and then (re)add the ones listed below: |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + pre_commit_detect_outdated: |
| 18 | + name: Detect outdated pre-commit hooks |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Python 3.12 |
| 24 | + uses: actions/setup-python@v4 |
| 25 | + with: |
| 26 | + python-version: 3.12 |
| 27 | + |
| 28 | + - name: Install pre-commit |
| 29 | + run: |- |
| 30 | + pip install \ |
| 31 | + --disable-pip-version-check \ |
| 32 | + --no-warn-script-location \ |
| 33 | + --user \ |
| 34 | + pre-commit |
| 35 | + echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}" |
| 36 | +
|
| 37 | + - name: Check for outdated hooks |
| 38 | + run: |- |
| 39 | + pre-commit autoupdate |
| 40 | + git diff -- .pre-commit-config.yaml |
| 41 | +
|
| 42 | + - name: Create pull request from changes (if any) |
| 43 | + id: create-pull-request |
| 44 | + uses: peter-evans/create-pull-request@v5 |
| 45 | + with: |
| 46 | + author: 'pre-commit <[email protected]>' |
| 47 | + base: master |
| 48 | + body: |- |
| 49 | + For your consideration. |
| 50 | +
|
| 51 | + :warning: Please **CLOSE AND RE-OPEN** this pull request so that [further workflow runs get triggered](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs) for this pull request. |
| 52 | + branch: precommit-autoupdate |
| 53 | + commit-message: "pre-commit: Autoupdate" |
| 54 | + delete-branch: true |
| 55 | + draft: true |
| 56 | + labels: enhancement |
| 57 | + title: "pre-commit: Autoupdate" |
| 58 | + |
| 59 | + - name: Log pull request URL |
| 60 | + if: "${{ steps.create-pull-request.outputs.pull-request-url }}" |
| 61 | + run: | |
| 62 | + echo "Pull request URL is: ${{ steps.create-pull-request.outputs.pull-request-url }}" |
0 commit comments