-
-
Notifications
You must be signed in to change notification settings - Fork 520
151 lines (124 loc) · 4.94 KB
/
locale-update.yml
File metadata and controls
151 lines (124 loc) · 4.94 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Locale Generate App Terms
on:
push:
branches:
- master
paths:
- 'src/**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
update-locale:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js (from .nvmrc)
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install gettext tools
run: sudo apt-get update && sudo apt-get install -y gettext
- name: Use Install.sql for DB initialization (blank DB)
run: |
if [ -f src/mysql/install/Install.sql ]; then
echo "Using Install.sql to initialize a blank DB"
cp src/mysql/install/Install.sql cypress/data/seed.sql
else
echo "Install.sql not found at src/mysql/install/Install.sql" >&2
exit 1
fi
- name: Start CI Docker containers
run: npm run docker:ci:start
- name: Wait for Docker to be ready
run: |
echo "Waiting for services to be ready..."
sleep 10
docker compose -f docker/docker-compose.yaml -f docker/docker-compose.gh-actions.yaml --profile ci ps -a
docker compose -f docker/docker-compose.yaml -f docker/docker-compose.gh-actions.yaml --profile ci logs
- name: Run locale build
run: npm run locale:build
- name: Stop CI Docker containers
if: always()
run: npm run docker:ci:down
- name: Check for meaningful changes
id: check_changes
run: |
# Check if there are any changes to .po files
# The main messages.po is in locale/terms/messages.po
PO_FILE="locale/terms/messages.po"
if [ ! -f "$PO_FILE" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No messages.po file found at $PO_FILE"
exit 0
fi
if git diff --quiet -- "$PO_FILE"; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No changes detected in locale files"
exit 0
fi
# Check if changes are only in the header (first 20 lines typically contain headers)
# We'll check if there are changes beyond line 25 to be safe
CHANGES=$(git diff -- "$PO_FILE" | grep -E '^\+[^+]|^\-[^-]' | tail -n +25 | wc -l)
if [ "$CHANGES" -gt 0 ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Meaningful changes detected: $CHANGES lines"
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "Only header changes detected, skipping PR creation"
fi
- name: Configure Git
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create locale update branch
if: steps.check_changes.outputs.has_changes == 'true'
run: |
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
BRANCH_NAME="locale/update-$TIMESTAMP"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
git checkout -b "$BRANCH_NAME"
- name: Commit locale changes
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git add locale/terms/messages.po src/locale/i18n/
git commit -m "Update locale strings from source code"
- name: Push branch
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git push origin "$BRANCH_NAME"
- name: Create Pull Request
if: steps.check_changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get the commit SHA that triggered this
TRIGGER_SHA="${{ github.sha }}"
TRIGGER_COMMIT_MSG=$(git log --format=%B -n 1 $TRIGGER_SHA)
gh pr create \
--title "Update locale strings" \
--body "This PR updates the locale translation strings extracted from source code.
## Triggered By
Commit: \`$TRIGGER_SHA\`
Message: $TRIGGER_COMMIT_MSG
## Changes
- Updated \`locale/terms/messages.po\` with new/modified translatable strings
- Updated JSON locale keys
## Next Steps
- Review the new strings that need translation
- Merge this PR to update the base locale file
- Upload to POEditor for translation if needed" \
--base ${{ github.ref_name }} \
--head "$BRANCH_NAME" \
--label "Localization"