generated from raspberrypilearning/default-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (77 loc) · 2.69 KB
/
nttt-processing.yml
File metadata and controls
87 lines (77 loc) · 2.69 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
name: NTTT processing
on:
# currently allowing manual trigger only
workflow_dispatch:
inputs:
branch:
description: 'Branch to process translations on'
required: false
default: 'l10n_crowdin_translations'
type: string
locale:
description: "Locale to process translations for (e.g. fr-FR). Leave blank to run all (except en)."
required: false
default: ''
type: string
permissions: write-all
jobs:
nttt-processing:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || 'l10n_crowdin_translations'}}
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11.0'
- name: Install NTTT from GitHub repository
run: |
python -m pip install --upgrade pip
pip install git+https://github.com/raspberrypilearning/nttt.git
- name: Run NTTT (single locale or all except 'en')
run: |
set -euo pipefail
LOCALE="${{ inputs.locale }}"
if [[ -n "$LOCALE" ]]; then
# Single-locale mode
if [[ "$LOCALE" == "en" ]]; then
echo "Skipping 'en' locale by design."
exit 0
fi
if [[ ! -d "$LOCALE" ]]; then
echo "Locale directory '$LOCALE' does not exist at repo root."
echo "Available locale dirs:"
ls -1d */ 2>/dev/null | sed 's#/##' || true
exit 1
fi
echo "Processing single locale: $LOCALE"
pushd "$LOCALE" >/dev/null
printf "y\n" | nttt -Y YES || true
popd >/dev/null
else
# All-locales mode (current behaviour)
for lang_dir in */; do
if [[ -d "$lang_dir" && "$lang_dir" != "en/" ]]; then
lang_code="$(basename "$lang_dir")"
echo "Processing language: $lang_code"
pushd "$lang_dir" >/dev/null
printf "y\n" | nttt -Y YES || true
popd >/dev/null
fi
done
fi
- name: Add changes to branch
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action - NTTT Processing"
git add .
if git diff --staged --quiet; then
echo "No changes after NTTT processing"
else
git commit -m "Apply NTTT processing to translations"
git push origin HEAD:${{ inputs.branch || 'l10n_crowdin_translations'}}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}