From fe70507693649a61a2007adda0b51c28ba8f6cac Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 20 Dec 2024 10:21:28 -0500 Subject: [PATCH 1/3] github: Elevate permisisons to allow creating branches and PRs. --- .github/workflows/update-translations.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/update-translations.yml b/.github/workflows/update-translations.yml index b0e934e287..e47774dd87 100644 --- a/.github/workflows/update-translations.yml +++ b/.github/workflows/update-translations.yml @@ -1,4 +1,7 @@ name: Update translations from Weblate +permissions: + contents: write + pull-requests: write on: schedule: - cron: "0 10 * * 1" From 0e7cd8622099723398a1c85e5a8aa061a58769b8 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 20 Dec 2024 10:23:01 -0500 Subject: [PATCH 2/3] github: Add steps to update generated code as well. --- .github/workflows/update-translations.yml | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/update-translations.yml b/.github/workflows/update-translations.yml index e47774dd87..9cc38e3e5a 100644 --- a/.github/workflows/update-translations.yml +++ b/.github/workflows/update-translations.yml @@ -6,17 +6,41 @@ on: schedule: - cron: "0 10 * * 1" workflow_dispatch: + jobs: update-translations: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Fetch and merge from Weblate # The commit message is generated in Weblate; see https://hosted.weblate.org/addon/17163/ run: | git remote add weblate https://hosted.weblate.org/git/zulip/zulip-flutter/ git fetch weblate git merge --ff-only weblate/main + + - name: Clone Flutter SDK + # TODO(#1204) reinstate shallow clone with --depth=1000 and its corresponding comment here + run: | + git clone -b main https://github.com/flutter/flutter ~/flutter + TZ=UTC git --git-dir ~/flutter/.git log -1 --format='%h | %ci | %s' --date=iso8601-local + echo ~/flutter/bin >> "$GITHUB_PATH" + + # The Flutter tool assumes the tip of tree is "origin/master" + # (or "upstream/master"): + # https://github.com/flutter/flutter/issues/160626 + # TODO(upstream): make workaround unneeded + git --git-dir ~/flutter/.git update-ref refs/remotes/origin/master origin/main + + - name: Update generated code + run: | + mkdir -p build + tools/check l10n --fix + git add lib/generated/l10n/ + GIT_COMMITTER_NAME="Hosted Weblate" GIT_COMMITTER_EMAIL="hosted@weblate.org" \ + git commit --amend -C HEAD + - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: From 7dff11028088dbaa20e6ff79244892430dd5d21b Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 8 Jan 2025 13:40:57 -0500 Subject: [PATCH 3/3] DO NOT MERGE: Run on this PR. --- .github/workflows/update-translations.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-translations.yml b/.github/workflows/update-translations.yml index 9cc38e3e5a..1fc63e27c2 100644 --- a/.github/workflows/update-translations.yml +++ b/.github/workflows/update-translations.yml @@ -3,6 +3,7 @@ permissions: contents: write pull-requests: write on: + pull_request: schedule: - cron: "0 10 * * 1" workflow_dispatch: @@ -12,13 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Fetch and merge from Weblate # The commit message is generated in Weblate; see https://hosted.weblate.org/addon/17163/ run: | + git checkout -b main + git log --oneline --graph --all -n5 git remote add weblate https://hosted.weblate.org/git/zulip/zulip-flutter/ git fetch weblate - git merge --ff-only weblate/main + GIT_COMMITTER_NAME="Hosted Weblate" GIT_COMMITTER_EMAIL="hosted@weblate.org" \ + git cherry-pick weblate/main ^HEAD - name: Clone Flutter SDK # TODO(#1204) reinstate shallow clone with --depth=1000 and its corresponding comment here @@ -47,3 +53,4 @@ jobs: branch: update-translations/weblate delete-branch: true title: Update translations from Weblate + base: ${{ github.head_ref }}