From 3a1092cf7da3ff11a0d5d68f882d7685565f1996 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Fri, 22 May 2026 15:58:04 +0200 Subject: [PATCH] Test sorting --- .gitea/workflows/pull_request.yaml | 67 ++++++++++++++++++++++++++---- pubspec.yaml | 1 + 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/pull_request.yaml b/.gitea/workflows/pull_request.yaml index 64df356..73cc434 100644 --- a/.gitea/workflows/pull_request.yaml +++ b/.gitea/workflows/pull_request.yaml @@ -101,12 +101,65 @@ jobs: echo "All messages translated." + sort_arb_files: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - - - + # Required for Flutter action + - name: Install jq + run: | + apt-get update + apt-get install -y jq -# git fetch origin ${{ gitea.ref_name }} -# git checkout ${{ gitea.ref_name }} -# git pull origin ${{ gitea.ref_name }} -# git push origin HEAD:${{ gitea.ref_name }} + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: 3.41.0 + + - name: Get dependencies + run: | + git config --global --add safe.directory /opt/hostedtoolcache/flutter/stable-3.41.0-x64 + flutter pub get + + - name: Sort .arb-Files + run: | + for file in lib/l10n/intl_*.arb; do + if [ -f "$file" ]; then + echo "Sorting $file" + dart run arb_utils sort $file + exit 1 + fi + done + + - name: Check for changes + id: check_changes + run: | + if [ -n "$(git status --porcelain lib/l10n/arb)" ]; then + echo "has_changes=true" >> "$GITHUB_OUTPUT" + else + echo "has_changes=false" >> "$GITHUB_OUTPUT" + fi + + - name: Commit generated localizations + if: steps.check_changes.outputs.has_changes == 'true' + env: + GITEA_TOKEN: ${{ secrets.BOT_TOKEN }} + BRANCH_NAME: ${{ gitea.head_ref }} + run: | + git fetch origin "$BRANCH_NAME" + git checkout "$BRANCH_NAME" + + if [ -n "$(git status --porcelain lib test)" ]; then + git config --global user.name "Gitea Actions [bot]" + git config --global user.email "actions@yannick-weigert.de" + git config pull.rebase false + git pull origin "$BRANCH_NAME" + git add lib/l10n + git commit -m "Generated localizations [skip ci]" + git push origin "HEAD:$BRANCH_NAME" + else + echo "No changes to commit" + fi \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index cb0bb83..7be69e7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: uuid: ^4.5.2 dev_dependencies: + arb_utils: ^0.11.0 flutter_test: sdk: flutter build_runner: ^2.7.0