Skip to content

Commit c6913fb

Browse files
Merge pull request #43 from raspberrypilearning/draft
Add workflow folder
2 parents d872279 + 6cdc518 commit c6913fb

File tree

5 files changed

+178
-0
lines changed

5 files changed

+178
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Create Crowdin project
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
crowdin-create:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
13+
- name: Create crowdin project
14+
uses: crowdin/github-action@v2
15+
with:
16+
command: "project add"
17+
command_args: "RPF-Project-${{ github.event.repository.name }} -l fr -l nl -l de -l hi -l it -l ja -l pt-BR -l es-419 -l uk"
18+
env:
19+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
20+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Crowdin Download Action
2+
3+
on:
4+
schedule:
5+
# Run every day at 1 AM UTC
6+
- cron: "0 1 * * *"
7+
workflow_dispatch: # Manual triggering
8+
9+
concurrency:
10+
group: crowdin-download
11+
cancel-in-progress: true
12+
13+
permissions: write-all
14+
15+
jobs:
16+
crowdin:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
ref: master
23+
24+
- name: Synchronize with Crowdin
25+
uses: crowdin/github-action@v2
26+
with:
27+
upload_sources: false
28+
upload_translations: false
29+
download_translations: true
30+
localization_branch_name: l10n_crowdin_translations
31+
create_pull_request: true
32+
pull_request_title: "New Crowdin translations"
33+
pull_request_body: "New Crowdin pull request with translations"
34+
pull_request_base_branch_name: "master"
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
38+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}

.github/workflows/hide-strings.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Crowdin Hide Strings
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Crowdin Upload Action"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
crowdin-upload:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Install Crowdin CLI
18+
run: |
19+
curl -L https://github.com/crowdin/crowdin-cli/releases/latest/download/crowdin-cli.zip -o crowdin-cli.zip
20+
unzip crowdin-cli.zip -d crowdin-cli
21+
mkdir -p ~/bin
22+
mv crowdin-cli/*/crowdin ~/bin/crowdin
23+
cp crowdin-cli/*/crowdin-cli.jar ~/bin/crowdin-cli.jar
24+
chmod +x ~/bin/crowdin
25+
echo "PATH=$HOME/bin:$PATH" >> $GITHUB_ENV
26+
27+
- name: Hide matching strings
28+
run: |
29+
crowdin --version
30+
crowdin string list --verbose | grep -E -- '--- /no-print ---|--- no-print|--- print-only|hero_image images/' | awk '{print $1}' | sed 's/^#//' | grep '^[0-9]\+$'
31+
while read -r id; do
32+
crowdin string edit "$id" --hidden
33+
done
34+
env:
35+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
36+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: NTTT processing
2+
3+
on:
4+
# currently allowing manual trigger only
5+
workflow_dispatch:
6+
inputs:
7+
branch:
8+
description: 'Branch to process translations on'
9+
required: false
10+
default: 'l10n_crowdin_translations'
11+
type: string
12+
13+
permissions: write-all
14+
15+
jobs:
16+
nttt-processing:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
ref: ${{ inputs.branch || 'l10n_crowdin_translations'}}
23+
24+
- name: Set up Python 3.11
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: '3.11.0'
28+
29+
- name: Install NTTT from GitHub repository
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install git+https://github.com/raspberrypilearning/nttt.git
33+
34+
- name: Run NTTT on all language directories except 'en'
35+
run: |
36+
for lang_dir in */; do
37+
if [[ -d "$lang_dir" && "$lang_dir" != "en/" ]]; then
38+
lang_code=$(basename "$lang_dir")
39+
echo "Processing language: $lang_code"
40+
cd "$lang_dir"
41+
printf "y\n" | nttt -Y YES || true
42+
cd ..
43+
fi
44+
done
45+
46+
- name: Add changes to branch
47+
run: |
48+
git config --local user.email "action@github.com"
49+
git config --local user.name "GitHub Action - NTTT Processing"
50+
git add .
51+
if git diff --staged --quiet; then
52+
echo "No changes after NTTT processing"
53+
else
54+
git commit -m "Apply NTTT processing to translations"
55+
git push origin HEAD:${{ inputs.branch || 'l10n_crowdin_translations'}}
56+
fi
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Crowdin Upload Action
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- master
8+
paths: ["en/**/*.*"]
9+
10+
jobs:
11+
crowdin-upload:
12+
if: github.event.pull_request.merged == true
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Crowdin push
19+
uses: crowdin/github-action@v2
20+
with:
21+
upload_sources: true
22+
upload_translations: false
23+
download_translations: false
24+
env:
25+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
26+
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}

0 commit comments

Comments
 (0)