-
Notifications
You must be signed in to change notification settings - Fork 7
/
action.yml
77 lines (67 loc) · 2.43 KB
/
action.yml
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
77
name: Update iterative/py-template
description: "Update py-template generated template"
branding:
icon: package
color: purple
inputs:
token:
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)'
default: ${{ github.token }}
runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install cruft
shell: bash
run: pip install cruft==2.15.0 # renovate: datasource=pypi
- name: Update template via cruft
shell: bash
id: cruft
run: |
echo "template=$(cat .cruft.json | jq '.template' -r)" >> $GITHUB_OUTPUT
echo "old_commit=$(cat .cruft.json | jq '.commit' -r)" >> $GITHUB_OUTPUT
cruft update -y
echo "new_commit=$(cat .cruft.json | jq '.commit' -r)" >> $GITHUB_OUTPUT
- name: Check current state
shell: bash
run: |
git status --untracked-files=all
git diff
- name: Try to apply reject hunks
shell: bash
id: apply-rejects
run: |
for reject in $(git ls-files --others --exclude-standard '*.rej'); do
file=${reject%.rej}
cat ${reject}
patch -p1 --merge --no-backup-if-mismatch ${file} < ${reject} || echo " - \`${file}\`" >> /tmp/conflicts
rm ${reject}
echo
echo 'conflicts<<EOF' >> $GITHUB_OUTPUT
test -f /tmp/conflicts && cat /tmp/conflicts >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
done
- name: Check diff
id: diff
shell: bash
run: |
git status --untracked-files=all
echo 'changes<<EOF' >> $GITHUB_OUTPUT
git diff >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Create PR
if: ${{ steps.diff.outputs.changes != '' }}
uses: peter-evans/create-pull-request@v7
with:
token: ${{ inputs.token }}
commit-message: update template
title: update template
draft: true
body: |
Automated changes to update template with ${{ steps.cruft.outputs.template }}.
${{ steps.apply-rejects.outputs.conflicts != '' && 'There may be merge conflicts in these files that may need to be resolved manually:' || '' }}
${{ steps.apply-rejects.outputs.conflicts }}
__See Changelog__: ${{ steps.cruft.outputs.template }}/compare/${{ steps.cruft.outputs.old_commit }}...${{ steps.cruft.outputs.new_commit }}.