-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (64 loc) · 2.53 KB
/
sync-language-repos.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Sync Language Repos
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
jobs:
sync-language-repos:
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.SYNC_L10N_APP_ID }}
private-key: ${{ secrets.SYNC_L10N_APP_PRIVATE_KEY }}
owner: MahoCommerce
- name: Checkout main repository
uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Get current date
id: date
run: echo "DATE=$(date +'%y.%-m.%-d')" >> $GITHUB_OUTPUT
- name: Sync language repos and tag
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
for dir in *_*/; do
lang=${dir%/}
# Skip en_US folder
if [ "$lang" == "en_US" ]; then
echo "Skipping en_US folder"
continue
fi
echo "Processing $lang"
# Try to clone the language-specific repo
if ! git clone https://x-access-token:[email protected]/mahocommerce/maho-language-$lang.git temp_$lang 2>/dev/null; then
echo "Repository for $lang does not exist. Skipping."
continue
fi
# Ensure the app/locale/xx_XX directory exists in the target repo
mkdir -p temp_$lang/app/locale/$lang
# Copy contents from main repo to the correct location in language-specific repo
rsync -av --delete $lang/ temp_$lang/app/locale/$lang/
# Check for changes
cd temp_$lang
if [[ $(git status --porcelain) ]]; then
echo "Changes detected in $lang"
git add .
git commit -m "Sync changes from main repository - ${{ steps.date.outputs.DATE }}"
git push origin main
# Tag new version
git tag -a ${{ steps.date.outputs.DATE }} -m "Version ${{ steps.date.outputs.DATE }}"
git push origin --tags
echo "Tagged new version ${{ steps.date.outputs.DATE }} for $lang"
else
echo "No changes in $lang"
fi
cd ..
# Clean up
rm -rf temp_$lang
done