-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (48 loc) · 1.6 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
name: Sync Weblate Commits
on:
push:
branches:
- main
jobs:
check-and-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout code
run: |
git clone https://github.com/racicLuka/weblate-test.git
cd weblate-test
git checkout main
- name: List Weblate Commits
id: weblate-commits
run: |
cd weblate-test
git fetch origin
output=$(git log --grep="Weblate" origin/main --format=%H)
declare -a commits=()
while IFS= read -r line; do
commits+=("$line")
done <<< "$output"
echo "$commits"
git fetch --prune --tags
branches_output=$(git branch -r | grep -v "origin/main" | cut -d'/' -f2 | xargs)
echo "new output $branches_output"
declare -a OTHER_BRANCHES=()
while IFS= read -r line; do
OTHER_BRANCHES+=("$line")
done <<< "$branches_output"
MISSING_COMMITS=()
MISSING_BRANCHES=()
for BRANCH in $OTHER_BRANCHES; do
for COMMIT in $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
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