Debian Codegraph @

l10n/.github/workflows/upstream-source-sync.yml

raw
1 name: Upstream Source Locale Sync
2
3 on:
4 # Run daily to pick up new source strings from uutils/coreutils
5 schedule:
6 - cron: '0 3 * * *'
7
8 # Allow manual triggering
9 workflow_dispatch:
10
11 # Serialize with weblate-sync: both push to main, and a source push landing
12 # mid-sync is what leaves Weblate behind and gets its push rejected.
13 concurrency:
14 group: l10n-sync
15 cancel-in-progress: false
16
17 jobs:
18 sync-upstream-sources:
19 runs-on: ubuntu-latest
20
21 steps:
22 - name: Checkout repository
23 uses: actions/checkout@v7
24 with:
25 token: ${{ secrets.WEBLATE_TOKEN || github.token }}
26 fetch-depth: 0
27
28 - name: Clone upstream uutils/coreutils
29 run: |
30 git clone --depth 1 https://github.com/uutils/coreutils.git /tmp/upstream-coreutils
31
32 - name: Sync en-US source locale
33 run: |
34 set -e
35
36 # Copy en-US.ftl from upstream for every utility/uucore dir that exists
37 # in both repos. Directories that only exist upstream (e.g. b2sum,
38 # md5sum, sha*sum, checksum_common — unified as hashsum here) or only
39 # here (e.g. vdir) are skipped.
40 #
41 # Only en-US (the source/template locale) is synced. French (fr-FR) is
42 # NOT synced from upstream — it is a normal Weblate-managed translation
43 # here, so syncing it would clobber Weblate's French and the two would
44 # fight over the same files.
45 changed=0
46 while IFS= read -r src; do
47 rel="${src#/tmp/upstream-coreutils/}"
48 dst="$rel"
49 if [ -f "$dst" ] && ! cmp -s "$src" "$dst"; then
50 cp "$src" "$dst"
51 echo "Updated: $dst"
52 changed=$((changed + 1))
53 fi
54 done < <(find /tmp/upstream-coreutils/src/uu/*/locales /tmp/upstream-coreutils/src/uucore/locales -name "en-US.ftl" -type f 2>/dev/null)
55 echo "Source locale files updated: $changed"
56
57 - name: Commit and push
58 run: |
59 git config --local user.email "[email protected]"
60 git config --local user.name "GitHub Action"
61
62 if [ -n "$(git status --porcelain)" ]; then
63 find src/uu/*/locales src/uucore/locales \
64 -name 'en-US.ftl' -type f -print0 \
65 | xargs -0 git add --
66 git commit -m "Sync en-US source locale from upstream uutils/coreutils"
67 # Pushing to main here will trigger weblate-sync.yml (on: push,
68 # paths: en-US.ftl), which handles pushing sources to Weblate.
69 git push
70 else
71 echo "No upstream source updates"
72 fi