From 0f0c40d02c9d5efb5ac4b5377caae701e4fe3f3f Mon Sep 17 00:00:00 2001 From: Junya Morioka Date: Wed, 9 Sep 2026 00:54:22 +0900 Subject: [PATCH] fix: open the child repository PR when Copier leaves conflicts - Stage files Copier could not merge; it writes them with inline conflict markers and leaves them unmerged, which made the pull request action fail on git checkout -B and dropped the whole update - Name the conflicting files in the pull request title, body and job log so the markers are resolved before the update is merged - Detect changes with git status instead of git diff, so an update that only adds files is no longer reported as no change --- .github/workflows/trigger-template-update.yml | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/trigger-template-update.yml b/.github/workflows/trigger-template-update.yml index ca87790..be512b7 100644 --- a/.github/workflows/trigger-template-update.yml +++ b/.github/workflows/trigger-template-update.yml @@ -28,6 +28,7 @@ jobs: uses: astral-sh/setup-uv@v10.0.1 - name: Update template in child repository + id: update working-directory: child-repo run: | # Update from template. --defaults answers prompts added since the @@ -35,11 +36,36 @@ jobs: # ask interactively and fail. uvx copier update -A --defaults --trust + # Copier writes conflicting files with inline markers and leaves them + # unmerged in the index, which stops the pull request action from + # creating its branch. Stage them so the pull request is still opened, + # and describe them so the markers are resolved before it is merged. + conflicts="$(git diff --name-only --diff-filter=U)" + if [ -n "${conflicts}" ]; then + echo "conflicts=true" >> "$GITHUB_OUTPUT" + { + echo "conflict_note<>>>>>>`); resolve every marker before merging.' + echo + echo "${conflicts}" | sed 's/^/- `/; s/$/`/' + echo "CONFLICT_NOTE_EOF" + } >> "$GITHUB_OUTPUT" + echo "${conflicts}" | sed 's/^/::warning::Conflict left for manual resolution in /' + git add -A + else + echo "conflicts=false" >> "$GITHUB_OUTPUT" + fi + - name: Check for changes id: changes working-directory: child-repo run: | - if git diff --quiet; then + # git diff alone would miss an update that only adds files, because + # those stay untracked until the pull request action commits them. + if [ -z "$(git status --porcelain)" ]; then echo "has_changes=false" >> $GITHUB_OUTPUT else echo "has_changes=true" >> $GITHUB_OUTPUT @@ -53,7 +79,7 @@ jobs: path: child-repo commit-message: | Update template to version ${{ github.event.release.tag_name || 'latest' }} - title: "Update template to version ${{ github.event.release.tag_name || 'latest' }}" + title: "Update template to version ${{ github.event.release.tag_name || 'latest' }}${{ steps.update.outputs.conflicts == 'true' && ' (resolve conflicts)' || '' }}" body: | ## Template Update @@ -64,6 +90,8 @@ jobs: - Template version: ${{ github.event.release.tag_name || 'latest' }} ${{ github.event.release.html_url && format('- Release notes: {0}', github.event.release.html_url) || '' }} + ${{ steps.update.outputs.conflict_note }} + ### Testing Please review the changes and test the updated template before merging.