Merge pull request #18 from Carvin-Yu/feature/JIRA-2222 #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update feature Branches | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
update-branches: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set Git config | |
run: | | |
git config --local user.email "actions@github.com" | |
git config --local user.name "Github Actions" | |
- name: Merge master back to feature | |
run: | | |
git fetch --unshallow | |
for branch in $(git branch -r --list "origin/feature/*"); do | |
branch_name=$(echo $branch | sed 's/origin\///') | |
git checkout -B $branch_name $branch || true | |
git pull || true | |
if git merge main --no-commit; then | |
git commit -m "Merge main into $branch_name" | |
git push origin $branch_name | |
else | |
git merge --abort | |
git reset --hard HEAD | |
continue | |
fi | |
done | |