@@ -28,18 +28,44 @@ jobs:
2828 uses : astral-sh/setup-uv@v10.0.1
2929
3030 - name : Update template in child repository
31+ id : update
3132 working-directory : child-repo
3233 run : |
3334 # Update from template. --defaults answers prompts added since the
3435 # child repository was last updated; without it Copier would try to
3536 # ask interactively and fail.
3637 uvx copier update -A --defaults --trust
3738
39+ # Copier writes conflicting files with inline markers and leaves them
40+ # unmerged in the index, which stops the pull request action from
41+ # creating its branch. Stage them so the pull request is still opened,
42+ # and describe them so the markers are resolved before it is merged.
43+ conflicts="$(git diff --name-only --diff-filter=U)"
44+ if [ -n "${conflicts}" ]; then
45+ echo "conflicts=true" >> "$GITHUB_OUTPUT"
46+ {
47+ echo "conflict_note<<CONFLICT_NOTE_EOF"
48+ echo "### Conflicts to resolve"
49+ echo
50+ echo "Copier could not merge these files. They are committed with conflict markers"
51+ echo '(`<<<<<<<`, `=======`, `>>>>>>>`); resolve every marker before merging.'
52+ echo
53+ echo "${conflicts}" | sed 's/^/- `/; s/$/`/'
54+ echo "CONFLICT_NOTE_EOF"
55+ } >> "$GITHUB_OUTPUT"
56+ echo "${conflicts}" | sed 's/^/::warning::Conflict left for manual resolution in /'
57+ git add -A
58+ else
59+ echo "conflicts=false" >> "$GITHUB_OUTPUT"
60+ fi
61+
3862 - name : Check for changes
3963 id : changes
4064 working-directory : child-repo
4165 run : |
42- if git diff --quiet; then
66+ # git diff alone would miss an update that only adds files, because
67+ # those stay untracked until the pull request action commits them.
68+ if [ -z "$(git status --porcelain)" ]; then
4369 echo "has_changes=false" >> $GITHUB_OUTPUT
4470 else
4571 echo "has_changes=true" >> $GITHUB_OUTPUT
5379 path : child-repo
5480 commit-message : |
5581 Update template to version ${{ github.event.release.tag_name || 'latest' }}
56- title : " Update template to version ${{ github.event.release.tag_name || 'latest' }}"
82+ title : " Update template to version ${{ github.event.release.tag_name || 'latest' }}${{ steps.update.outputs.conflicts == 'true' && ' (resolve conflicts)' || '' }} "
5783 body : |
5884 ## Template Update
5985
6490 - Template version: ${{ github.event.release.tag_name || 'latest' }}
6591 ${{ github.event.release.html_url && format('- Release notes: {0}', github.event.release.html_url) || '' }}
6692
93+ ${{ steps.update.outputs.conflict_note }}
94+
6795 ### Testing
6896 Please review the changes and test the updated template before merging.
6997
0 commit comments