Skip to content

Commit

Permalink
Rebase org- branches on trunk (#6456)
Browse files Browse the repository at this point in the history
- Adding github actions to automatically rebase org- branches on trunk
  when master get's a merge
  • Loading branch information
Martin-Molinero authored Jul 1, 2022
1 parent 30e47f3 commit b426483
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/rebase-org-branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Rebase Organization Branches

on:
push:
branches:
- 'master'

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Rebase Organization Branches
run: |
chmod +x rebase_organization_branches.sh
./rebase_organization_branches.sh
env:
QC_GIT_TOKEN: ${{ secrets.QC_GIT_TOKEN }}
26 changes: 26 additions & 0 deletions rebase_organization_branches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

echo "Start Rebasing Organization Branches"
git config user.name "$(git log -n 1 --pretty=format:%an)"
git config user.email "$(git log -n 1 --pretty=format:%ae)"

git remote set-branches origin '*'
git checkout -- .
git clean -xqdf

for branch in $(git for-each-ref refs/remotes/origin/* | cut -d"$(printf '\t')" -f2 | cut -b21- | grep ^org-)
do
echo "Rebasing branch $branch"
git checkout $branch
git rebase master
retVal=$?
if [ $retVal -eq 0 ]; then
echo "Pushing branch $branch"
git push --force-with-lease --set-upstream origin $branch
else
echo "Rebase failed branch $branch"
git rebase --abort
fi
git checkout master
git clean -xqdf
done

0 comments on commit b426483

Please sign in to comment.