@@ -30,18 +30,32 @@ jobs:
3030 permissions :
3131 contents : write
3232 pull-requests : write
33+
3334 steps :
34- # Checkout code
35+ # -- 1. Checkout full history so we can push a branch -------------------
3536 - name : Checkout code
36- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+ uses : actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
38+ with :
39+ fetch-depth : 0
40+
41+ # -- 2. Configure git for authenticated fetches ------------------------
42+ - name : Configure git for GitHub authentication
43+ run : |
44+ git config --global url."https://x-access-token:${{ secrets.GH_PAT_TOKEN }}@github.com/".insteadOf "https://github.com/"
45+
46+ # -- 3. Set commit author identity (fixes 'please tell me who you are')
47+ - name : Set git author
48+ run : |
49+ git config --global user.name "github-actions[bot]"
50+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
3751
38- # Set up Python
52+ # -- 4. Set up Python ---------------------------------------------------
3953 - name : Set up Python
40- uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6 .0
54+ uses : actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1 .0
4155 with :
4256 python-version : ' 3.x'
4357
44- # Cache pip dependencies
58+ # -- 5. Cache pip dependencies -----------------------------------------
4559 - name : Cache pip dependencies
4660 uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4761 with :
@@ -50,19 +64,45 @@ jobs:
5064 restore-keys : |
5165 ${{ runner.os }}-pip-
5266
53- # Install pre-commit
67+ # -- 6. Install pre-commit ---------------------------------------------
5468 - name : Install pre-commit
55- run : pip install --require-hashes -r requirements.txt
69+ run : pip install --require-hashes -r .github/pip- requirements.txt
5670
57- # Run pre- commit autoupdate
71+ # -- 7. Run autoupdate (with --freeze) and commit if something changed --
5872 - name : Run pre-commit autoupdate
59- run : pre-commit autoupdate
73+ id : update
74+ run : |
75+ pre-commit autoupdate --freeze
76+ pre-commit migrate-config
77+ git add .pre-commit-config.yaml
78+ if ! git diff --cached --quiet; then
79+ git commit -m "chore: update pre-commit hooks"
80+ echo "changed=true" >> "$GITHUB_OUTPUT"
81+ fi
6082
61- # Create pull request
83+ # -- 8. Check if there are changes to commit -----------------------------
84+ - name : Configure git for PAT
85+ run : |
86+ git config --global url."https://x-access-token:${{ secrets.GH_PAT_TOKEN }}@github.com/".insteadOf "https://github.com/"
87+
88+ # -- 9. Push changes if there are any --------------------------------------
6289 - name : Create pull request
90+ if : steps.update.outputs.changed == 'true'
6391 uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
6492 with :
93+ token : ${{ secrets.GH_PAT_TOKEN }}
6594 commit-message : " chore: update pre-commit hooks"
66- title : " chore: update pre-commit hooks"
67- body : " This PR updates all pre-commit hooks to their latest versions."
95+ title : " chore(deps): update pre-commit hooks"
96+ body : |
97+ This automated pull request updates all pre-commit hooks to their latest versions as of this week.
98+
99+ **What's changed:**
100+ - All hooks in `.pre-commit-config.yaml` have been updated using `pre-commit autoupdate --freeze`.
101+ - The configuration has been migrated if needed.
102+
103+ **Why this matters:**
104+ - Keeps code quality tools up-to-date.
105+ - Ensures compatibility and security with the latest hook releases.
106+
107+ **No manual action is required** unless you notice issues with the updated hooks. Please review and merge if everything looks good.
68108 branch : " chore/update-pre-commit-hooks"
0 commit comments