|
1 | 1 | on: |
2 | 2 | push: |
3 | 3 | branches: main |
4 | | - paths: "**/translate-en-messages.py" |
| 4 | + paths: |
| 5 | + - "translate-messages/**" |
| 6 | + - "!translate-messages/*.config.json" |
5 | 7 |
|
6 | 8 | jobs: |
7 | 9 | build: |
@@ -86,20 +88,28 @@ jobs: |
86 | 88 | REPO_SYNC_PAT: ${{ secrets.REPO_SYNC_PAT }} |
87 | 89 | run: | |
88 | 90 | 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" |
91 | 92 | for repo in "${TARGET_REPOS[@]}"; do |
92 | 93 | echo "::group::Replacing translate-en-messages.py in $repo" |
93 | 94 | repo_path="${repo//\//_}" |
94 | 95 | target_dir="$GITHUB_WORKSPACE/$repo_path" |
95 | 96 | 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" |
102 | 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 |
103 | 113 | fi |
104 | 114 | done |
105 | 115 | git diff-index --quiet HEAD || (echo "Committing changes" && \ |
|
0 commit comments