Skip to content

Commit 28f0825

Browse files
committed
feat:(workflow) add sync-target-files.yml
1 parent 90c8804 commit 28f0825

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Sync Translation Target Files
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
sync-files:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout current repository
13+
uses: actions/checkout@v4
14+
15+
- name: Clone floorp repository
16+
run: |
17+
git clone https://github.com/Floorp-Projects/floorp-12.git floorp
18+
cd floorp
19+
git checkout main
20+
21+
- name: Read translation targets
22+
id: read-targets
23+
run: |
24+
TARGETS=$(cat src/apps/i18n-supports/translation-targets.json)
25+
echo "targets=$TARGETS" >> $GITHUB_OUTPUT
26+
27+
- name: Generate Crowdin.yml
28+
run: |
29+
TARGETS='${{ steps.read-targets.outputs.targets }}'
30+
echo "files:" > crowdin.yml
31+
echo "$TARGETS" | jq -c '.targets[]' | while read -r target; do
32+
SOURCE_PATH=$(echo "$target" | jq -r '.source_apth')
33+
SOURCE_FILE=$(echo "$TARGETS" | jq -r '.source_file')
34+
echo "" >> crowdin.yml
35+
echo " - source: /$SOURCE_PATH/$SOURCE_FILE" >> crowdin.yml
36+
echo " translation: /$SOURCE_PATH/%locale%.json" >> crowdin.yml
37+
done
38+
39+
- name: Copy translation files
40+
run: |
41+
TARGETS='${{ steps.read-targets.outputs.targets }}'
42+
echo "$TARGETS" | jq -c '.targets[]' | while read -r target; do
43+
SOURCE_PATH=$(echo "$target" | jq -r '.source_apth')
44+
F18N_PATH=$(echo "$target" | jq -r '.f18n_path')
45+
SOURCE_FILE=$(echo "$TARGETS" | jq -r '.source_file')
46+
echo "Copying $SOURCE_FILE from $SOURCE_PATH to $F18N_PATH"
47+
mkdir -p "$F18N_PATH"
48+
cp "floorp/$SOURCE_PATH/$SOURCE_FILE" "$F18N_PATH"
49+
done
50+
51+
- name: Commit and push changes
52+
run: |
53+
git config --local user.email "action@github.com"
54+
git config --local user.name "GitHub Action"
55+
git add .
56+
git commit -m "chore: sync translation target files and update crowdin.yml" || exit 0
57+
git push

0 commit comments

Comments
 (0)