Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

fix(translations): translation updates no longer get stuck or lost when main changes during sync (#16796)

Bartosz Majewski3dbe47966bfb
diff --git a/.github/workflows/crowdin-pr-merger.yml b/.github/workflows/crowdin-pr-merger.yml
index a5342975251..d4cd04b2ae9 100644
--- a/.github/workflows/crowdin-pr-merger.yml
+++ b/.github/workflows/crowdin-pr-merger.yml
@@ -22,6 +22,7 @@ jobs:
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
+ fetch-depth: 0
- name: Cache dependencies
uses: actions/cache@v5
@@ -63,7 +64,26 @@ jobs:
echo "Resetting branch to match remote repository..."
git reset --hard origin/${{ github.event.pull_request.head.ref }}
git clean -fd
-
+
+ - name: Merge latest main
+ run: |
+ git config --local user.email "[email protected]"
+ git config --local user.name "automated-commits-ap"
+ if ! git merge --no-edit origin/main; then
+ for FILE in $(git diff --name-only --diff-filter=U); do
+ if ! git cat-file -e "origin/main:$FILE" 2>/dev/null; then
+ git rm -q -- "$FILE"
+ continue
+ fi
+ case "$FILE" in
+ */locales/*/translation.json|*/i18n/*.json) git checkout --ours -- "$FILE" ;;
+ *) git checkout --theirs -- "$FILE" ;;
+ esac
+ git add -- "$FILE"
+ done
+ git commit --no-edit
+ fi
+
- name: Run Node.js script
run: |
echo "Running Node.js script..."
@@ -75,26 +95,19 @@ jobs:
# Check if there are any changes
if [[ -n "$(git status --porcelain)" ]]; then
echo "Changes detected, committing..."
-
- # Configure git
- git config --local user.email "[email protected]"
- git config --local user.name "automated-commits-ap"
-
+
# Add all changes
git add .
# Commit with a descriptive message
git commit -m "chore: auto bump translated pieces"
-
- # Push changes back to the PR branch
- git push origin HEAD:${{ github.event.pull_request.head.ref }}
-
- echo "Changes committed and pushed to PR branch"
+
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "No changes detected, skipping commit"
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
+ git push origin HEAD:${{ github.event.pull_request.head.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/generate-translations.yml b/.github/workflows/generate-translations.yml
index e0c45802444..ea367268574 100644
--- a/.github/workflows/generate-translations.yml
+++ b/.github/workflows/generate-translations.yml
@@ -76,7 +76,7 @@ jobs:
notify-failure:
# Only run when any of the shards failed; still evaluate even if they failed
if: ${{ github.repository == 'activepieces/activepieces' && always() && contains(needs.*.result, 'failure') }}
- needs: [shard-0, shard-1, shard-2, shard-3, shard-4, shard-5]
+ needs: [shard-0, shard-1, shard-2, shard-3, shard-4, shard-5, finalize]
runs-on: ubuntu-latest
steps:
- name: Notify Discord on shard failure
diff --git a/.github/workflows/reusable-finalize-translations-pr.yml b/.github/workflows/reusable-finalize-translations-pr.yml
index 3a6fc016740..0dc09d2dade 100644
--- a/.github/workflows/reusable-finalize-translations-pr.yml
+++ b/.github/workflows/reusable-finalize-translations-pr.yml
@@ -16,6 +16,7 @@ jobs:
uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
+ fetch-depth: 0
- name: Cache dependencies
uses: actions/cache@v5
@@ -54,6 +55,27 @@ jobs:
git checkout -b $BRANCH_NAME origin/main
fi
+ - name: Merge latest main
+ run: |
+ git fetch origin main
+ if ! git merge --no-edit origin/main; then
+ CONFLICTS=$(git diff --name-only --diff-filter=U)
+ for FILE in $CONFLICTS; do
+ if git cat-file -e "origin/main:$FILE" 2>/dev/null; then
+ git checkout --theirs -- "$FILE"
+ git add -- "$FILE"
+ else
+ git rm -q -- "$FILE"
+ fi
+ done
+ git commit --no-edit
+ for FILE in $(echo "$CONFLICTS" | grep '/src/i18n/translation.json$'); do
+ if [ -f "$FILE" ]; then
+ npm run cli pieces generate-translation-file -- "$(basename "$(dirname "$(dirname "$(dirname "$FILE")")")")"
+ fi
+ done
+ fi
+
- name: Generate translation files for UI
run: npm run i18n:extract
@@ -64,10 +86,10 @@ jobs:
if [ -n "$(git status --porcelain)" ]; then
git add -A
git commit -m "feat: update UI translations [skip-changelog]"
- git push origin $BRANCH_NAME
else
echo "No changes for UI translations in react app"
fi
+ git push origin $BRANCH_NAME
- name: Check branch ahead of main
id: ahead
@@ -76,14 +98,18 @@ jobs:
run: |
git fetch origin
git checkout $BRANCH_NAME
- LEFT_RIGHT=$(git rev-list --left-right --count origin/main...HEAD)
- AHEAD=$(echo $LEFT_RIGHT | awk '{print $2}')
- if [ "$AHEAD" -gt 0 ]; then
- echo "changes=true" >> $GITHUB_OUTPUT
- else
+ if git diff --quiet origin/main HEAD; then
echo "changes=false" >> $GITHUB_OUTPUT
+ else
+ echo "changes=true" >> $GITHUB_OUTPUT
fi
+ - name: Delete unchanged branch
+ if: steps.ahead.outputs.changes == 'false'
+ env:
+ BRANCH_NAME: ${{ inputs.branch_name }}
+ run: git push origin --delete $BRANCH_NAME
+
- name: Create Pull Request
if: steps.ahead.outputs.changes == 'true'
uses: actions/github-script@v8