-
Notifications
You must be signed in to change notification settings - Fork 7
61 lines (50 loc) · 1.84 KB
/
pre-commit-autoupdate.yml
File metadata and controls
61 lines (50 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Pre-commit Autoupdate
on:
schedule:
# Run weekly on Monday at 9am UTC
- cron: "0 9 * * 1"
workflow_dispatch:
permissions: {}
jobs:
autoupdate:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: true
- name: Generate GitHub App token
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2
id: app-token
with:
app-id: ${{ vars.AUTOMATION_APP_ID }}
private-key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }}
- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
- name: Run prek autoupdate
working-directory: "{{cookiecutter.project_slug}}"
run: uvx prek autoupdate --freeze --cooldown-days 7
- name: Create Pull Request
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
if git diff --quiet; then
echo "No changes to commit"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
branch="pre-commit-autoupdate"
git checkout -b "$branch"
git add -A
git commit -m "build(deps): update pre-commit hooks"
git push --force origin "$branch"
if gh pr view "$branch" &>/dev/null; then
echo "PR already exists"
else
gh pr create \
--title "build(deps): update pre-commit hooks" \
--body "Automated update of pre-commit hooks using \`prek autoupdate --freeze --cooldown-days 7\`.
This PR was auto-generated by the pre-commit-autoupdate workflow."
fi