Skip to content

Commit 7f3b21b

Browse files
committed
Updated job to cover dir
1 parent 59fbe1a commit 7f3b21b

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

.github/workflows/sync-translate-en-messages.py-changes-to-repos.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
on:
22
push:
33
branches: main
4-
paths: "**/translate-en-messages.py"
4+
paths:
5+
- "translate-messages/**"
6+
- "!translate-messages/*.config.json"
57

68
jobs:
79
build:
@@ -86,20 +88,28 @@ jobs:
8688
REPO_SYNC_PAT: ${{ secrets.REPO_SYNC_PAT }}
8789
run: |
8890
TARGET_REPOS=(${{ steps.list_repos.outputs.REPOS }})
89-
source_file="${{ github.workspace }}/adamlui/python-utils/translate-messages/translate-en-messages.py"
90-
source_timestamp=$(cd "${{ github.workspace }}/adamlui/python-utils" && git log -1 --format="%ct" -- "translate-messages/translate-en-messages.py")
91+
SOURCE_DIR="${{ github.workspace }}/adamlui/python-utils/translate-messages"
9192
for repo in "${TARGET_REPOS[@]}"; do
9293
echo "::group::Replacing translate-en-messages.py in $repo"
9394
repo_path="${repo//\//_}"
9495
target_dir="$GITHUB_WORKSPACE/$repo_path"
9596
cd "$target_dir" || exit 1
96-
target_files=$(find . -name "translate-en-messages.py" -type f)
97-
for target_file in $target_files; do
98-
target_timestamp=$(git log -1 --format="%ct" -- "$target_file")
99-
if [[ $source_timestamp -gt $target_timestamp ]]; then
100-
echo "Copying $source_file to $target_file"
101-
cp -f "$source_file" "$target_file"
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"
102104
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
103113
fi
104114
done
105115
git diff-index --quiet HEAD || (echo "Committing changes" && \

0 commit comments

Comments
 (0)