-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (50 loc) · 1.73 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
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"
git fetch --prune --tags
branches_output=$(git branch -r | grep -v "origin/main" | cut -d'/' -f2 | xargs)
declare -a OTHER_BRANCHES=()
while IFS= read -r word; do
OTHER_BRANCHES+=("$word")
done <<< "$branches_output"
MISSING_COMMITS=()
MISSING_BRANCHES=()
for BRANCH in $OTHER_BRANCHES; do
echo "this is the branch $BRANCH"
for COMMIT in $COMMITS; do
echo "this is the commit $COMMIT"
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 config --global user.email "[email protected]"
git config --global user.name "racicLuka"
git cherry-pick ${MISSING_COMMITS[$i]}
git push origin HEAD
done