sync_repo.sh 499 B

1234567891011121314151617181920212223242526
  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. git checkout $CI_BUILD_REF_NAME
  9. if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  10. git pull --rebase origin $CI_BUILD_REF_NAME
  11. fi
  12. if git remote | grep github > /dev/null; then
  13. git remote rm github
  14. fi
  15. git remote add github $GITHUB_DEST
  16. if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  17. git push github $CI_BUILD_REF_NAME
  18. else
  19. git push github --tags
  20. fi