Skip to content

all in one run

all in one run #35

Workflow file for this run

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
output=$(git branch -r | grep -v "origin/main" | cut -d'/' -f2 | xargs)
declare -a OTHER_BRANCHES=()
while IFS= read -r line; do
OTHER_BRANCHES+=("$line")
done <<< "$output"
echo "these are the other branches $OTHER_BRANCHES"
MISSING_COMMITS=()
MISSING_BRANCHES=()
echo "branches ${{ steps.set-other-branches.outputs.other_branches }}"
echo "commits ${{ steps.weblate-commits.outputs.commits }}"
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"
echo "$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