Skip to content

Update sync-weblate.yml #12

Update sync-weblate.yml

Update sync-weblate.yml #12

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
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_ENV
- name: Check for Commits in Other Branches
id: check-other-branches
run: |
OTHER_BRANCHES=$(git branch --format='%(refname:short)' | grep -v "main")
MISSING_COMMITS=()
MISSING_BRANCHES=()
while IFS= read -r branch; do
while IFS= read -r commit; do
if ! git branch --contains "$commit" | grep -q "$branch"; then
MISSING_COMMITS+=("$commit")
MISSING_BRANCHES+=("$branch")
fi
done <<< "${{ env.COMMITS }}"
done <<< "$OTHER_BRANCHES"
echo "missing_commits=${MISSING_COMMITS[*]}" >> $GITHUB_ENV
echo "missing_branches=${MISSING_BRANCHES[*]}" >> $GITHUB_ENV
- name: Pull Weblate Commits to Other Branches
if: env.missing_commits != ''
run: |
MISSING_COMMITS=($MISSING_COMMITS)
MISSING_BRANCHES=($MISSING_BRANCHES)
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