-
Notifications
You must be signed in to change notification settings - Fork 3
76 lines (62 loc) · 2.22 KB
/
Copy pathcruft_update.yml
File metadata and controls
76 lines (62 loc) · 2.22 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Update repository with Cruft
permissions:
contents: write
pull-requests: write
on:
schedule:
- cron: "0 4 * * 1" # Every Monday at 4am
workflow_dispatch: # manually
env:
python-version: 3.12
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv and set the python version to ${{ env.python-version }}
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ env.python-version }}
- name: Install Cruft
run: uv pip install cruft
- name: Check if update is available
continue-on-error: false
id: check
run: |
CHANGES=0
if [ -f .cruft.json ]; then
if ! cruft check; then
CHANGES=1
fi
else
echo "No .cruft.json file"
fi
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub"
cruft update --skip-apply-ask --refresh-private-variables
# --------------------------------------------------------
# HARD BLOCK: never allow workflow updates from Cruft
# --------------------------------------------------------
git restore --staged .github/workflows || true
git restore .github/workflows || true
- name: Create pull request
if: steps.check.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: .
commit-message: "chore: accept new Cruft update"
branch: cruft/update
delete-branch: true
branch-suffix: timestamp
title: New updates detected with Cruft
body: |
This is an autogenerated PR.
[Cruft](https://cruft.github.io/cruft/) has detected updates from the
Cookiecutter repository.
Changes to `.github/workflows` are intentionally excluded
from automated updates and must be applied manually.