@@ -38,11 +38,14 @@ jobs:
3838 # Create temporary directory for fork-specific files
3939 mkdir -p /tmp/fork-specific
4040
41- # Get list of all files in current branch
42- FILES_TO_CHECK=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
41+ # Identify fork-specific workflow files (files that don't exist in upstream)
42+ git fetch upstream master
43+
44+ # Get list of workflow files in fork
45+ FORK_WORKFLOWS=$(git ls-tree -r HEAD --name-only .github/workflows/ 2>/dev/null || echo "")
4346
4447 # For each file in fork, check if it exists in upstream (files that don't = fork-specific)
45- for file in $FILES_TO_CHECK ; do
48+ for file in $FORK_WORKFLOWS ; do
4649 if ! git cat-file -e upstream/master:"$file" 2>/dev/null; then
4750 echo "Fork-specific file: $file"
4851 # Create directory structure and copy file
5255 done
5356
5457 # Check if any fork-specific files were found
55- if [ -d "/tmp/fork-specific" ] && find /tmp/fork-specific -type f -print -quit | grep -q . ; then
58+ if [ -d "/tmp/fork-specific/.github " ]; then
5659 echo "has_fork_files=true" >> $GITHUB_OUTPUT
5760 echo "Found fork-specific files:"
5861 find /tmp/fork-specific -type f
@@ -69,13 +72,13 @@ jobs:
6972 - name : Restore fork-specific files
7073 if : steps.backup.outputs.has_fork_files == 'true'
7174 run : |
72- # Copy all fork-specific files back
75+ # Copy fork-specific files back
7376 if [ -d "/tmp/fork-specific" ]; then
74- cp -r /tmp/fork-specific/* ./ 2>/dev/null || true
77+ cp -r /tmp/fork-specific/.github ./ 2>/dev/null || true
7578 fi
7679
7780 # Add all fork-specific changes
78- git add .
81+ git add .github/
7982
8083 - name : Commit fork-specific changes
8184 if : steps.backup.outputs.has_fork_files == 'true'
9598
9699 sync-manual :
97100 name : Sync Fork (Manual)
98- if : contains(github.event.comment.body, '/sync-upstream')
101+ if : |
102+ github.event_name == 'issue_comment' &&
103+ contains(github.event.comment.body, '/sync-upstream')
99104 runs-on : ubuntu-latest
100105 permissions :
101106 contents : write
@@ -173,11 +178,14 @@ jobs:
173178 # Create temporary directory for fork-specific files
174179 mkdir -p /tmp/fork-specific
175180
176- # Get list of all files in current branch
177- FILES_TO_CHECK=$(git ls-tree -r HEAD --name-only 2>/dev/null || echo "")
181+ # Identify fork-specific workflow files (files that don't exist in upstream)
182+ git fetch upstream master
183+
184+ # Get list of workflow files in fork
185+ FORK_WORKFLOWS=$(git ls-tree -r HEAD --name-only .github/workflows/ 2>/dev/null || echo "")
178186
179187 # For each file in fork, check if it exists in upstream (files that don't = fork-specific)
180- for file in $FILES_TO_CHECK ; do
188+ for file in $FORK_WORKFLOWS ; do
181189 if ! git cat-file -e upstream/master:"$file" 2>/dev/null; then
182190 echo "Fork-specific file: $file"
183191 # Create directory structure and copy file
@@ -187,7 +195,7 @@ jobs:
187195 done
188196
189197 # Check if any fork-specific files were found
190- if [ -d "/tmp/fork-specific" ] && find /tmp/fork-specific -type f -print -quit | grep -q . ; then
198+ if [ -d "/tmp/fork-specific/.github " ]; then
191199 echo "has_fork_files=true" >> $GITHUB_OUTPUT
192200 echo "Found fork-specific files:"
193201 find /tmp/fork-specific -type f
@@ -206,13 +214,13 @@ jobs:
206214 - name : Restore fork-specific files
207215 if : steps.backup.outputs.has_fork_files == 'true'
208216 run : |
209- # Copy all fork-specific files back
217+ # Copy fork-specific files back
210218 if [ -d "/tmp/fork-specific" ]; then
211- cp -r /tmp/fork-specific/* ./ 2>/dev/null || true
219+ cp -r /tmp/fork-specific/.github ./ 2>/dev/null || true
212220 fi
213221
214222 # Add all fork-specific changes
215- git add .
223+ git add .github/
216224
217225 - name : Commit fork-specific changes
218226 if : steps.backup.outputs.has_fork_files == 'true'
0 commit comments