-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
github: Fix weblate action's rights, and update generated code. #1262
Open
alexmv
wants to merge
3
commits into
main
Choose a base branch
from
action-rights-generated
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,56 @@ | ||
name: Update translations from Weblate | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
on: | ||
pull_request: | ||
schedule: | ||
- cron: "0 10 * * 1" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-translations: | ||
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="[email protected]" \ | ||
git cherry-pick weblate/main ^HEAD | ||
|
||
- 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="[email protected]" \ | ||
git commit --amend -C HEAD | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
branch: update-translations/weblate | ||
delete-branch: true | ||
title: Update translations from Weblate | ||
base: ${{ github.head_ref }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I guess there's a race where if origin/main just got updated and Weblate hasn't taken that update yet, the
merge --ff-only
will fail.How about
reset --hard
? Then the PR's base will be slightly behind the tip, but that's normal. We'll rebase it forward as part of merge like we do for many other PRs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, this change is part of the "run on this PR" don't-merge commit. Never mind, then.
(There still is that race, but it's unlikely.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One option is we can
git reset --hard weblate/main
and let the PR potentially be behindmain
if weblate is lagging. Which means one might get a PR with "cannot merge" rather than the failure one gets withgit merge --ff-only
, which is that the whole action fails.