sync_repo.sh 603 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. set -ex
  3. GITHUB_DEST=$1
  4. if echo $CI_BUILD_REF_NAME | grep private; then
  5. echo 'sync no private branches'
  6. exit 0
  7. fi
  8. if echo $CI_BUILD_REF_NAME | grep cherry-pick-; then
  9. echo 'sync no cherry-pick branches'
  10. exit 0
  11. fi
  12. git checkout $CI_BUILD_REF_NAME
  13. if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  14. git pull --rebase origin $CI_BUILD_REF_NAME
  15. fi
  16. if git remote | grep github > /dev/null; then
  17. git remote rm github
  18. fi
  19. git remote add github $GITHUB_DEST
  20. if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  21. git push github $CI_BUILD_REF_NAME
  22. else
  23. git push github --tags
  24. fi