Skip to content

Commit 5351f54

Browse files
committed
setup autofix for translation issues
1 parent fde4d10 commit 5351f54

File tree

2 files changed

+247
-35
lines changed

2 files changed

+247
-35
lines changed

.github/workflows/validate-translations.yml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,71 @@ on:
44
pull_request:
55
paths:
66
- 'i18n/**'
7-
- 'scripts/validate-translations.js'
8-
- 'package.json'
97
push:
108
branches:
11-
- 'main'
12-
- 'long_lived/**'
13-
- 'release/**'
9+
- 'l10n_crowdin_translations'
1410
paths:
1511
- 'i18n/**'
16-
- 'scripts/validate-translations.js'
17-
- 'package.json'
1812

1913
concurrency:
20-
group: ${{ github.event_name == 'pull_request' && format('{0}-{1}', github.workflow_ref, github.event.pull_request.number) || github.run_id }}
14+
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}--${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
2115
cancel-in-progress: true
2216

2317
permissions:
24-
contents: read
18+
contents: write
19+
pull-requests: write
2520

2621
jobs:
2722
validate:
2823
name: Validate translation files
29-
runs-on: ubuntu-latest
24+
runs-on: [k8s-public]
25+
container: node:20
3026
timeout-minutes: 10
27+
if: |
28+
(github.event_name == 'pull_request' && github.head_ref == 'l10n_crowdin_translations') ||
29+
(github.event_name == 'push' && github.ref == 'refs/heads/l10n_crowdin_translations')
3130
3231
steps:
33-
- name: Checkout Code
34-
uses: actions/checkout@v5
32+
- name: Add safe git directory
33+
uses: Chia-Network/actions/git-mark-workspace-safe@main
3534

36-
- name: Setup Node.js
37-
uses: actions/setup-node@v4
35+
- name: Checkout
36+
uses: actions/checkout@v5
3837
with:
39-
node-version: '20'
40-
cache: 'npm'
38+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
4139

4240
- name: Install dependencies
43-
run: npm ci
41+
run: npm install
42+
43+
- name: Validate and fix translations
44+
run: npm run validate:translations -- --fix
45+
46+
- name: Check for changes
47+
id: changes
48+
run: |
49+
if [ -n "$(git status --porcelain)" ]; then
50+
echo "has_changes=true" >> $GITHUB_OUTPUT
51+
else
52+
echo "has_changes=false" >> $GITHUB_OUTPUT
53+
fi
54+
55+
- name: Set up commit signing
56+
if: steps.changes.outputs.has_changes == 'true'
57+
uses: Chia-Network/actions/commit-sign/gpg@main
58+
with:
59+
gpg_private_key: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_KEY_RSA }}
60+
passphrase: ${{ secrets.CHIA_AUTOMATION_PRIVATE_GPG_PASSPHRASE }}
4461

45-
- name: Validate translations
46-
run: npm run validate:translations
62+
- name: Commit fixes
63+
if: steps.changes.outputs.has_changes == 'true'
64+
run: |
65+
git config --local user.email "[email protected]"
66+
git config --local user.name "Chia Automation"
67+
git add .
68+
git commit -m "chore: auto-fix translation validation issues" || true
69+
if [ "${{ github.event_name }}" == "pull_request" ]; then
70+
git push origin HEAD:${{ github.head_ref }} || true
71+
else
72+
git push || true
73+
fi
4774

0 commit comments

Comments
 (0)