|
4 | 4 | pull_request: |
5 | 5 | paths: |
6 | 6 | - 'i18n/**' |
7 | | - - 'scripts/validate-translations.js' |
8 | | - - 'package.json' |
9 | 7 | push: |
10 | 8 | branches: |
11 | | - - 'main' |
12 | | - - 'long_lived/**' |
13 | | - - 'release/**' |
| 9 | + - 'l10n_crowdin_translations' |
14 | 10 | paths: |
15 | 11 | - 'i18n/**' |
16 | | - - 'scripts/validate-translations.js' |
17 | | - - 'package.json' |
18 | 12 |
|
19 | 13 | 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 || '' }} |
21 | 15 | cancel-in-progress: true |
22 | 16 |
|
23 | 17 | permissions: |
24 | | - contents: read |
| 18 | + contents: write |
| 19 | + pull-requests: write |
25 | 20 |
|
26 | 21 | jobs: |
27 | 22 | validate: |
28 | 23 | name: Validate translation files |
29 | | - runs-on: ubuntu-latest |
| 24 | + runs-on: [k8s-public] |
| 25 | + container: node:20 |
30 | 26 | 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') |
31 | 30 |
|
32 | 31 | 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 |
35 | 34 |
|
36 | | - - name: Setup Node.js |
37 | | - uses: actions/setup-node@v4 |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v5 |
38 | 37 | with: |
39 | | - node-version: '20' |
40 | | - cache: 'npm' |
| 38 | + ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} |
41 | 39 |
|
42 | 40 | - 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 }} |
44 | 61 |
|
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 |
47 | 74 |
|
0 commit comments