瀏覽代碼

Create qt_translation_update.yml

George King 2 月之前
父節點
當前提交
7ad089a118
共有 1 個文件被更改,包括 77 次插入0 次删除
  1. 77 0
      .github/workflows/qt_translation_update.yml

+ 77 - 0
.github/workflows/qt_translation_update.yml

@@ -0,0 +1,77 @@
+name: Weekly Qt translation refresh
+
+on:
+  schedule:
+    - cron: '0 0 * * 0'   # Runs every Sunday at 00:00 UTC
+  workflow_dispatch:
+
+permissions:
+  contents: write
+
+env:
+  CURRENT_BRANCH: ${{ github.ref_name }}
+
+jobs:
+  refresh:
+    name: Qt translations refresh
+    runs-on: ubuntu-latest
+    
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+        with:
+          ref: ${{ env.CURRENT_BRANCH }}
+          fetch-depth: 0
+
+      - name: Install Qt tools (lupdate)
+        run: |
+          sudo apt install -y --no-install-recommends qttools5-dev-tools
+
+        # Update all TS files; remove obsolete entries
+      - name: Update TS files (Launcher)
+        working-directory: launcher
+        run: |
+          lupdate -no-obsolete . -ts translation/*.ts
+
+      - name: Update TS files (Map Editor)
+        working-directory: mapeditor
+        run: |
+          lupdate -no-obsolete . -ts translation/*.ts
+
+      - name: Show changed files
+        run: |
+          echo "Changed files (working tree):"
+          git status --porcelain || true
+          echo
+          echo "Diff names (unstaged):"
+          git diff --name-only || true
+
+      - name: Stage translation changes explicitly
+        run: |
+          git add -A launcher/translation mapeditor/translation || true
+          echo "Staged for commit:"
+          git diff --cached --name-only || true
+
+      - name: Detect staged changes
+        id: staged
+        run: |
+          COUNT=$(git diff --cached --name-only | wc -l)
+          echo "count=$COUNT" >> "$GITHUB_OUTPUT"
+          if [ "$COUNT" -eq 0 ]; then
+            echo "No staged translation changes."
+          else
+            echo "Staged $COUNT file(s)."
+          fi
+
+      - name: Commit and push changes
+        if: ${{ steps.staged.outputs.count != '0' }}
+        uses: EndBug/add-and-commit@v9
+        with:
+          add: "launcher/translation mapeditor/translation"
+          default_author: github_actions
+          message: "Auto-update VCMI Qt translation files"
+          push: true
+
+      - name: No-op summary
+        if: ${{ steps.staged.outputs.count == '0' }}
+        run: echo "No translation changes detected; nothing to commit."