2016-08-21 19:33:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
GITHUB_DEST=$1
|
|
|
|
|
2022-03-08 10:19:01 +00:00
|
|
|
git remote prune origin
|
|
|
|
|
2016-08-21 19:33:09 +00:00
|
|
|
if echo $CI_BUILD_REF_NAME | grep private; then
|
|
|
|
echo 'sync no private branches'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-08-23 13:43:09 +00:00
|
|
|
if echo $CI_BUILD_REF_NAME | grep cherry-pick-; then
|
|
|
|
echo 'sync no cherry-pick branches'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-04-18 08:21:10 +00:00
|
|
|
if echo $CI_BUILD_REF_NAME | grep dependabot/; then
|
|
|
|
echo 'sync no dependabot branches'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-08-21 19:33:09 +00:00
|
|
|
git checkout $CI_BUILD_REF_NAME
|
2016-10-19 05:25:10 +00:00
|
|
|
if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
|
2022-03-08 10:19:01 +00:00
|
|
|
git reset --hard origin/$CI_BUILD_REF_NAME
|
2016-10-19 05:25:10 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if git remote | grep github > /dev/null; then
|
|
|
|
git remote rm github
|
|
|
|
fi
|
2016-08-21 19:33:09 +00:00
|
|
|
git remote add github $GITHUB_DEST
|
2016-10-19 05:25:10 +00:00
|
|
|
|
|
|
|
if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
|
2022-03-08 10:19:01 +00:00
|
|
|
git push -f github $CI_BUILD_REF_NAME
|
2016-10-19 05:25:10 +00:00
|
|
|
else
|
|
|
|
git push github --tags
|
|
|
|
fi
|