-
Notifications
You must be signed in to change notification settings - Fork 19
49 lines (41 loc) · 1.31 KB
/
translations-check.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
name: Check Translation Files Sorting
on:
pull_request:
paths:
- "app/assets/json/translations/react/*.json"
jobs:
check-sorting:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Verify jq installation
run: |
if ! command -v jq &> /dev/null; then
echo "jq could not be found, installing..."
sudo apt-get update && sudo apt-get install -y jq
else
echo "jq is already installed: $(jq --version)"
fi
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install dependencies
run: npm install --global jsonlint-cli
- name: Validate and check sorting of translation files
run: |
for file in app/assets/json/translations/react/*.json; do
echo "Checking $file"
jsonlint-cli $file
jq -S '.' $file > sorted.json
if ! diff -uw $file sorted.json > differences.txt; then
echo "Sorting errors found in $file:"
cat differences.txt
rm sorted.json differences.txt
exit 1
else
echo "$file is properly sorted."
rm sorted.json
fi
done