@@ -83,37 +83,32 @@ jobs:
8383 git config --global user.email "auto-sync@kudoai.com"
8484 git config --global user.signingkey "$GPG_PRIVATE_ID"
8585
86- - name : Replace outdated files in target repos, push changes
86+ - name : Replace translate-messages/ in target repos, push changes
8787 env :
8888 REPO_SYNC_PAT : ${{ secrets.REPO_SYNC_PAT }}
8989 run : |
9090 TARGET_REPOS=(${{ steps.list_repos.outputs.REPOS }})
9191 SOURCE_DIR="${{ github.workspace }}/adamlui/python-utils/translate-messages"
92+
9293 for repo in "${TARGET_REPOS[@]}"; do
93- echo "::group::Replacing translate-en- messages.py in $repo"
94+ echo "::group::Syncing translate-messages/ in $repo"
9495 repo_path="${repo//\//_}"
9596 target_dir="$GITHUB_WORKSPACE/$repo_path"
9697 cd "$target_dir" || exit 1
97- find "$SOURCE_DIR" -type f ! -name "*.config.json" | while read source_file; do
98- rel_path="${source_file#$SOURCE_DIR/}"
99- target_file="$target_dir/translate-messages/$rel_path"
100- mkdir -p "$(dirname "$target_file")"
101- if [ ! -f "$target_file" ]; then
102- echo "Adding $target_file"
103- cp "$source_file" "$target_file"
104- git add "$target_file"
105- else
106- source_ts=$(cd "$SOURCE_DIR" && git log -1 --format="%ct" -- "$rel_path")
107- target_ts=$(git log -1 --format="%ct" -- "$target_file")
108- if [[ $source_ts -gt $target_ts ]]; then
109- echo "Updating $target_file"
110- cp "$source_file" "$target_file"
111- git add "$target_file"
112- fi
113- fi
98+
99+ # Copy src files to each target translate-messages/ dir
100+ mapfile -t TARGET_DIRS < <(find . -type d -name "translate-messages")
101+ for tdir in "${TARGET_DIRS[@]}" ; do
102+ echo "Copying files to $tdir..."
103+ rsync -av --delete --filter='P *.config.json' --exclude '*.config.json' "$SOURCE_DIR/" "$tdir/"
104+ git add "$tdir"
114105 done
115- git diff-index --quiet HEAD || (echo "Committing changes" && \
116- git commit -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/python-utils/tree/main/translate-messages]")
106+
107+ # Commit & push if any changes
108+ git diff-index --quiet HEAD || (
109+ echo "Committing changes"
110+ git commit -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/python-utils/tree/main/translate-messages]"
111+ )
117112 git remote set-url --push origin "https://kudo-sync-bot:$REPO_SYNC_PAT@github.com/$repo"
118113 echo "Pushing changes"
119114 git push --force
0 commit comments