-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (50 loc) · 2 KB
/
sync-weblate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Sync Weblate Commits
on:
push:
branches:
- main
jobs:
check-and-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: List Weblate Commits
id: weblate-commits
run: |
git fetch origin
COMMITS=$(git log --grep="Weblate" origin/main --format=%H)
echo "{commits}=$COMMITS" >> $GITHUB_OUTPUT
- name: Set Other Branches
id: set-other-branches
run: |
git fetch --prune --tags
OTHER_BRANCHES=$(git branch -r | grep -v "origin/main" | cut -d'/' -f2 | xargs)
echo "these are the other branches $OTHER_BRANCHES"
echo "{other_branches}=$OTHER_BRANCHES" >> $GITHUB_OUTPUT
- name: Check for Commits in Other Branches
id: check-other-branches
run: |
MISSING_COMMITS=()
MISSING_BRANCHES=()
for BRANCH in ${{ steps.set-other-branches.outputs.other_branches }}; do
for COMMIT in ${{ steps.weblate-commits.outputs.commits }}; do
if ! git branch --contains $COMMIT | grep -q "remotes/origin/$BRANCH"; then
echo "Commit $COMMIT does not exist in branch $BRANCH"
MISSING_COMMITS+=($COMMIT)
MISSING_BRANCHES+=($BRANCH)
fi
done
done
echo "{missing_commits}=$MISSING_COMMITS[*]" >> $GITHUB_OUTPUT
echo "{missing_branches}=$MISSING_BRANCHES[*]" >> $GITHUB_OUTPUT
- name: Pull Weblate Commits to Other Branches
run: |
MISSING_COMMITS=(${{ steps.check-other-branches.outputs.missing_commits }})
MISSING_BRANCHES=(${{ steps.check-other-branches.outputs.missing_branches }})
echo "these are the missing commits $MISSING_COMMITS"
for ((i=0; i<=${#MISSING_COMMITS[@]}; ++i)); do
git checkout ${MISSING_BRANCHES[$i]}
git cherry-pick ${MISSING_COMMITS[$i]}
done
git push origin $OTHER_BRANCHES