sync_repo.sh 575 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. set -ex
  3. GITHUB_DEST=$1
  4. git remote prune origin
  5. if echo $CI_BUILD_REF_NAME | grep -E "^(private|cherry-pick-|renovate/|dependabot/)"; then
  6. echo 'Do not sync internal branches.'
  7. exit 0
  8. fi
  9. git checkout $CI_BUILD_REF_NAME
  10. if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  11. git reset --hard origin/$CI_BUILD_REF_NAME
  12. fi
  13. if git remote | grep github > /dev/null; then
  14. git remote rm github
  15. fi
  16. git remote add github $GITHUB_DEST
  17. if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  18. git push -f github $CI_BUILD_REF_NAME
  19. else
  20. git push github --tags
  21. fi