|
| 1 | +name: 'Update Pre-commit Hooks' |
| 2 | +description: 'Updates pre-commit hook versions and creates a PR if changes are detected' |
| 3 | +inputs: |
| 4 | + token: |
| 5 | + description: 'GitHub token for creating PRs' |
| 6 | + required: true |
| 7 | + python-version: |
| 8 | + description: 'Python version to use' |
| 9 | + required: false |
| 10 | + default: '3.13' |
| 11 | + |
| 12 | +runs: |
| 13 | + using: composite |
| 14 | + steps: |
| 15 | + - name: Set up Python |
| 16 | + uses: actions/setup-python@v5 |
| 17 | + with: |
| 18 | + python-version: ${{ inputs.python-version }} |
| 19 | + - name: Install pre-commit |
| 20 | + shell: bash |
| 21 | + run: pip install pre-commit |
| 22 | + - name: Update pre-commit hooks |
| 23 | + shell: bash |
| 24 | + run: | |
| 25 | + pre-commit autoupdate > /tmp/autoupdate.log 2>&1 |
| 26 | + cat /tmp/autoupdate.log |
| 27 | + - name: Check for changes |
| 28 | + id: changes |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + if git diff --quiet .pre-commit-config.yaml; then |
| 32 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 33 | + else |
| 34 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 35 | + fi |
| 36 | + - name: Create Pull Request |
| 37 | + if: steps.changes.outputs.changed == 'true' |
| 38 | + uses: peter-evans/create-pull-request@v7 |
| 39 | + with: |
| 40 | + token: ${{ inputs.token }} |
| 41 | + commit-message: "[pre-commit] Update hooks versions" |
| 42 | + title: "[pre-commit] Update hooks versions" |
| 43 | + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
| 44 | + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
| 45 | + body: | |
| 46 | + 🤖 This PR was created automatically by the update-pre-commit workflow. |
| 47 | + branch: update-pre-commit-hooks |
| 48 | + base: master |
| 49 | + delete-branch: true |
| 50 | + labels: | |
| 51 | + dependencies |
0 commit comments