Install, configure, and maintain content for Ubuntu webserver
So, this might not be quite in line with your 100% automation approach, but the best way to provide a shell script access to a git repository is to use ssh keys to allow access to your git repository. Of course, this means you either need to log on and set up that key and grant access it to Git  (goodbye 100% automation) or securely copy a private key that already has access to the repository to your server. You'll probably want to keep that key someplace that requires a password to access it, so... chicken and the egg scenario. Unless your cloud provider gives you the ability to create a template that already has that key on it's file system when it's created. If you can do that, then you definitely want to go the ssh route.

Your clone would look something like this.

git clone ssh://username@bitbucket.org/username/repository.git




Okay, let's review your code now.


You're using sudo very liberally. It would be better to set file permissions appropriately. You can run into weirdness when using sudo along with git. You can end up with a repository on the file system owned by root and.. it can get messy.
There's no error handling what so ever. If any given step of your script fails, it will continue on trying to execute the next line. 
If you needed to change the location of the repository, you'd need to change the /var/www/html string in 3 different places. If your repository changes locations, it would change in 2. Use variables appropriately.