Skip to content

Commit 7e8a697

Browse files
Use git show to restore workflow files without staging
- Remove workflow files from index before committing merge - Restore workflow files to working directory using git show (doesn't stage) - Ensures workflow files are not included in the merge commit
1 parent 1279b3f commit 7e8a697

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.github/workflows/refresh_repository.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,22 @@ jobs:
7878
# Merge upstream changes
7979
git merge --no-edit upstream/master || true
8080
81-
# Remove workflow files from the merge completely
82-
echo "Excluding workflow files from merge - removing from index"
81+
# Merge upstream changes (this may include workflow file changes)
82+
git merge --no-edit upstream/master || true
83+
84+
# Remove workflow files from the merge commit
85+
echo "Excluding workflow files from merge commit"
86+
# Remove workflow files from index (they won't be in the commit)
8387
git rm --cached -r .github/workflows/ 2>/dev/null || true
8488
85-
# Restore workflow files to pre-merge version from working directory
86-
echo "Restoring workflow files to current version"
87-
git checkout $CURRENT_COMMIT -- .github/workflows/ || true
89+
# Restore workflow files to pre-merge state in working directory only (not staged)
90+
# Use git show to extract files without staging them
91+
for file in $(git ls-tree -r --name-only $CURRENT_COMMIT | grep '^\.github/workflows/'); do
92+
mkdir -p $(dirname "$file")
93+
git show $CURRENT_COMMIT:"$file" > "$file" 2>/dev/null || true
94+
done
8895
89-
# Complete the merge without workflow files
96+
# Complete the merge commit (workflow files are not in index, so won't be committed)
9097
if [[ -f .git/MERGE_HEAD ]]; then
9198
git commit --no-edit || true
9299
fi

0 commit comments

Comments
 (0)