Skip to content

Commit 2b16feb

Browse files
committed
feat: Add dual-mode translation workflow for PR testing
Enhanced the translation workflow to support two operational modes: ## 🧪 Testing Mode (NEW) - Triggers on every PR commit - Triggers on push to claude/** and translations/** branches - Updates .ts file directly in current branch - Does NOT create new PRs - Provides immediate feedback during development - Perfect for validating translation extraction ## 🚀 Production Mode (Existing) - Triggers weekly (Sunday midnight UTC) - Triggers on manual workflow dispatch - Creates new branch (translations/auto-update-YYYYMMDD-HHMMSS) - Creates Pull Request for review - Isolated translation updates ## Key Features - Automatic mode detection based on event type - Enhanced logging with emojis and clear status - Diff stats showing translation changes - Summary output for both modes - Path-based triggers (.cpp, .h, .qml, .ui, .ts files) ## Benefits Testing Mode: ✅ No extra PRs during development ✅ Keeps translations in sync with code changes ✅ Immediate validation of workflow ✅ Easy to review changes in context Production Mode: ✅ Weekly automation ensures completeness ✅ Clean separation of translation work ✅ Easy for translators to review ✅ Professional PR with full context ## Documentation Added comprehensive TRANSLATION-WORKFLOW.md covering: - Detailed explanation of both modes - Trigger conditions and examples - Workflow output samples - Usage guide for developers, translators, maintainers - Troubleshooting section - Best practices - Weblate integration notes This allows testing the workflow in PRs while maintaining clean automated weekly updates for translators.
1 parent 0c748bf commit 2b16feb

2 files changed

Lines changed: 448 additions & 9 deletions

File tree

.github/workflows/update-translations.yml

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ on:
44
workflow_dispatch: # Manual trigger
55
schedule:
66
- cron: '0 0 * * 0' # Weekly on Sunday at midnight
7+
pull_request: # Run on every PR commit for testing
8+
paths:
9+
- 'src/**/*.cpp'
10+
- 'src/**/*.h'
11+
- 'src/**/*.qml'
12+
- 'src/**/*.ui'
13+
- 'src/**/*.ts'
14+
push: # Run on push to PR branches
15+
branches:
16+
- 'claude/**' # All Claude Code branches
17+
- 'translations/**' # Translation-specific branches
718

819
jobs:
920
update-translations:
@@ -26,27 +37,64 @@ jobs:
2637
modules: 'qtcharts qtnetworkauth qtwebsockets'
2738
cache: true
2839

40+
- name: Detect workflow context
41+
id: context
42+
run: |
43+
if [ "${{ github.event_name }}" = "pull_request" ] || [ "${{ github.event_name }}" = "push" ]; then
44+
echo "mode=testing" >> $GITHUB_OUTPUT
45+
echo "🧪 Running in TESTING mode (PR/push to branch)"
46+
else
47+
echo "mode=production" >> $GITHUB_OUTPUT
48+
echo "🚀 Running in PRODUCTION mode (scheduled/manual)"
49+
fi
50+
2951
- name: Update translation files
3052
run: |
31-
# Run lupdate to extract translatable strings
53+
echo "Extracting translatable strings from source code..."
3254
lupdate src/qdomyos-zwift.pri -ts src/qdomyos-zwift.ts
3355
56+
echo ""
57+
echo "Checking for changes..."
58+
3459
# Check if there are changes
3560
if git diff --quiet src/qdomyos-zwift.ts; then
36-
echo "No translation updates needed"
61+
echo "No translation updates needed - file is up to date"
3762
echo "HAS_CHANGES=false" >> $GITHUB_ENV
3863
else
39-
echo "Translation file updated"
64+
echo "📝 Translation file has been updated with new/modified strings"
4065
echo "HAS_CHANGES=true" >> $GITHUB_ENV
66+
67+
# Show diff stats
68+
echo ""
69+
echo "Changes summary:"
70+
git diff --stat src/qdomyos-zwift.ts
4171
fi
4272
43-
- name: Commit and push changes
44-
if: env.HAS_CHANGES == 'true'
73+
- name: Commit and push changes (Testing Mode)
74+
if: env.HAS_CHANGES == 'true' && steps.context.outputs.mode == 'testing'
4575
run: |
4676
git config --local user.email "github-actions[bot]@users.noreply.github.com"
4777
git config --local user.name "github-actions[bot]"
4878
49-
# Create a new branch
79+
# Commit to current branch (PR branch)
80+
git add src/qdomyos-zwift.ts
81+
git commit -m "chore: update translation strings [automated]
82+
83+
Automatic update of translatable strings extracted from source code.
84+
85+
- Updated by GitHub Actions (Testing Mode)
86+
- Triggered by: ${{ github.event_name }}
87+
- Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
88+
89+
echo "✅ Changes committed to current branch"
90+
91+
- name: Commit and push changes (Production Mode)
92+
if: env.HAS_CHANGES == 'true' && steps.context.outputs.mode == 'production'
93+
run: |
94+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
95+
git config --local user.name "github-actions[bot]"
96+
97+
# Create a new branch for production updates
5098
BRANCH_NAME="translations/auto-update-$(date +%Y%m%d-%H%M%S)"
5199
git checkout -b "$BRANCH_NAME"
52100
@@ -56,17 +104,18 @@ jobs:
56104
57105
Automatic update of translatable strings extracted from source code.
58106
59-
- Updated by GitHub Actions
107+
- Updated by GitHub Actions (Scheduled)
60108
- Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
61109
62110
# Push the branch
63111
git push origin "$BRANCH_NAME"
64112
65113
# Store branch name for PR creation
66114
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
115+
echo "✅ Changes pushed to new branch: $BRANCH_NAME"
67116
68-
- name: Create Pull Request
69-
if: env.HAS_CHANGES == 'true'
117+
- name: Create Pull Request (Production Mode Only)
118+
if: env.HAS_CHANGES == 'true' && steps.context.outputs.mode == 'production'
70119
uses: peter-evans/create-pull-request@v5
71120
with:
72121
token: ${{ secrets.GITHUB_TOKEN }}
@@ -97,3 +146,27 @@ jobs:
97146
labels: |
98147
translations
99148
automation
149+
150+
- name: Summary
151+
if: always()
152+
run: |
153+
echo ""
154+
echo "============================================"
155+
echo "Translation Workflow Summary"
156+
echo "============================================"
157+
echo "Mode: ${{ steps.context.outputs.mode }}"
158+
echo "Event: ${{ github.event_name }}"
159+
echo "Has changes: ${{ env.HAS_CHANGES }}"
160+
echo "============================================"
161+
162+
if [ "${{ env.HAS_CHANGES }}" = "true" ]; then
163+
if [ "${{ steps.context.outputs.mode }}" = "testing" ]; then
164+
echo "✅ Translation file updated in current branch"
165+
echo " Review changes in: src/qdomyos-zwift.ts"
166+
else
167+
echo "✅ Translation file updated and PR created"
168+
echo " Branch: ${{ env.BRANCH_NAME }}"
169+
fi
170+
else
171+
echo "ℹ️ No updates needed - translation file is current"
172+
fi

0 commit comments

Comments
 (0)