-
Notifications
You must be signed in to change notification settings - Fork 155
111 lines (97 loc) · 3.21 KB
/
i18n_sync.yml
File metadata and controls
111 lines (97 loc) · 3.21 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Sync i18n files
on:
schedule:
- cron: "0 12 * * *"
push:
branches: [main]
paths:
- "src/lang/en/**"
pull_request:
paths:
- ".github/workflows/i18n*.yml"
workflow_dispatch:
jobs:
sync_i18n:
name: Generate and i18n files
runs-on: ubuntu-latest
steps:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Checkout frontend codes
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Checkout backend codes
uses: actions/checkout@v4
with:
repository: ${{ vars.SYNC_LANG_ENV_BACKEND_REPOSITORY || 'OpenListTeam/OpenList' }}
path: backend
fetch-depth: 0
submodules: recursive
- name: Generate and update lang files
run: |
cd backend
go run ./main.go lang --frontend-path ../
cd ..
- name: Check for changes and stage
id: verify-changed-files
run: |
cp -f ./backend/lang/*.json ./src/lang/en/ 2>/dev/null || :
if git diff --quiet HEAD -- src/lang/en/; then
echo "No changes detected in src/lang/en/"
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in src/lang/en/"
git add src/lang/en/
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Import GPG key
if: steps.verify-changed-files.outputs.changed == 'true'
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Setup CI Bot
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --global user.name "The OpenList Bot"
git config --global user.email "bot@openlist.team"
- name: Commit the changes
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git commit -S -m "chore: auto update i18n file"
# Skip pushing if triggered by a pull request
if [ "${{ github.event_name }}" != "pull_request" ]; then
git push
fi
- name: Setup Node
if: steps.verify-changed-files.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"
- name: Install pnpm
if: steps.verify-changed-files.outputs.changed == 'true'
uses: pnpm/action-setup@v4
with:
# version: 9.9.0
run_install: false
- name: Install dependencies
if: steps.verify-changed-files.outputs.changed == 'true'
run: pnpm install
- name: Sync to Crowdin
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
pnpm crowdin:upload
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
permissions:
contents: write