@@ -2,16 +2,15 @@ name: Reverse Sync
22
33env :
44 TARGET_REPO : alaudadevops/tektoncd-operator
5+ IGNORE_PATHS : .github/,README.md
6+ SYNCED_PATHS : docs/ theme/ .yarn/ doom.config.yml yarn.lock tsconfig.json package.json sites.yaml
57
68on :
79 pull_request :
810 types : [closed]
911 branches :
1012 - main
1113 - release-*
12- paths :
13- - ' *'
14- - ' !README.md'
1514
1615
1716jobs :
@@ -77,13 +76,17 @@ jobs:
7776 echo "base_commit=$base_commit" >> $GITHUB_OUTPUT
7877
7978 # Get list of changed files in the PR
80- git diff --name-only $base_commit $merge_commit > ../changed_files.txt
79+ ignore_pattern=$(echo "$IGNORE_PATHS" | sed 's/,/|/g' | sed 's|/$||g')
80+ echo "🙈 Ignored paths: $ignore_pattern"
81+
82+ git diff --name-only $base_commit $merge_commit | grep -v -E "^($ignore_pattern)" > ../changed_files.txt
8183
8284 echo "📋 Changed files in PR:"
8385 cat ../changed_files.txt
8486
87+ IFS=',' read -ra PATHS <<< "$SYNCED_PATHS"
8588 # Check if any documentation files were changed
86- if grep -E "(^docs/|^README\.md$)" .. /changed_files.txt; then
89+ if [ -s .. /changed_files.txt ] ; then
8790 echo "has_doc_changes=true" >> $GITHUB_OUTPUT
8891 echo "✅ Documentation changes detected"
8992 else
@@ -117,7 +120,9 @@ jobs:
117120 base_commit="${{ steps.get_changes.outputs.base_commit }}"
118121
119122 # Create a patch with only the documentation changes
120- git format-patch $base_commit..$merge_commit --stdout -- docs/ README.md > ../changes.patch
123+ ignore_pattern=$(echo "$IGNORE_PATHS" | sed 's/,/|/g' | sed 's|/$||g')
124+ echo "📑 Will only sync these paths: $SYNCED_PATHS"
125+ git format-patch $base_commit..$merge_commit --stdout -- $SYNCED_PATHS > ../changes.patch
121126
122127 cd ../target-docs
123128
@@ -129,12 +134,10 @@ jobs:
129134
130135 # Fallback: manual copy of changed files
131136 while IFS= read -r file; do
132- if [[ "$file" == docs/* ]] || [[ "$file" == "README.md" ]]; then
133- if [ -f "../devops-pipelines-docs/$file" ]; then
134- mkdir -p "$(dirname "$file")"
135- cp "../devops-pipelines-docs/$file" "$file"
136- echo "✅ Copied: $file"
137- fi
137+ if [ -f "../devops-pipelines-docs/$file" ]; then
138+ mkdir -p "$(dirname "$file")"
139+ cp "../devops-pipelines-docs/$file" "$file"
140+ echo "✅ Copied: $file"
138141 fi
139142 done < ../changed_files.txt
140143 }
@@ -143,12 +146,10 @@ jobs:
143146
144147 # Manual copy approach
145148 while IFS= read -r file; do
146- if [[ "$file" == docs/* ]] || [[ "$file" == "README.md" ]]; then
147- if [ -f "../devops-pipelines-docs/$file" ]; then
148- mkdir -p "$(dirname "$file")"
149- cp "../devops-pipelines-docs/$file" "$file"
150- echo "✅ Copied: $file"
151- fi
149+ if [ -f "../devops-pipelines-docs/$file" ]; then
150+ mkdir -p "$(dirname "$file")"
151+ cp "../devops-pipelines-docs/$file" "$file"
152+ echo "✅ Copied: $file"
152153 fi
153154 done < ../changed_files.txt
154155 fi
0 commit comments