sync_repo.sh 732 B

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