Local bash script to deploy acquia cloud

Hi, on one of my projects I was faced with problem of deploying code to acquia cloud environment assuming that theme files were generated by grunt. As far as I know acquia do not allow to install grunt on their servers so I had to create custom shell script to deploy code from my local. Probably the next step is setting up jenkins and triggering deploy with git hooks but for now it is quite enough for this website. I hope this info will be helpful for someone.

Thank you

//Please wrote code!
# Deploy acquia dev environment.
# Move to local themes folder.
cd /var/www/your_site/your_theme
# Switch to develop branch.
git checkout develop 
# Pull from remote develop branch (change placeholders GitUserName and GitPassword).
git pull https://GitUserName:GitPassword@bitbucket.org/your_git_repo.git develop
# Run grunt -f job.
grunt -f 
# Push develop to acquia repo.
git push acquia develop
# Sync local generated files with remote.
# your_acquia_subscription - name of your acquia site. environment - one of dev, test, prod.
rsync -rtcpWzP /var/www/your_site/files/release/   your_acquia_subscription.dev@staging-XXXXX.prod.hosting.acquia.com:/var/www/html/your_site/files/release
# Use dev drush alias.
drush use @he.dev
# Clear dev drupal cache.
drush cc all
# Clear acquia varnish cache for dev domains.
# secret acquia key can be found at https://accounts.acquia.com/account/acquia_uid/security?destination=account/security 
# Cloud API => Private key.
# your_acquia_subscription - name of your acquia site. environment - one of dev, test, prod.
curl -u your_email:my_secret_acquia_key -X DELETE https://cloudapi.acquia.com/v1/sites/prod:your_acquia_subscription/envs/dev/domains/your_acquia_domain_to_purge/cache.json
curl -u your_email:my_secret_acquia_key -X DELETE https://cloudapi.acquia.com/v1/sites/prod:your_acquia_subscription/envs/dev/domains/your_acquia_domain_to_purge/cache.json


#Deploy stage and put new branch number.
cd /var/www/your_site/your_theme
# Checkout to master git branch.
git checkout master
# Pull latest master branch changes.
output="$(git pull https://GitUserName:GitPassword@bitbucket.org/your_git_repo.git master)"
# If everything is up-to-date we avoid updating.
if [ "$output" = 'Already up-to-date.' ] 
  then
    echo "don't need to update stage";
  else
    echo "We need to update stage";
        # Run grunt job.
	grunt -f
	# Push master changes to acquia remote.
	git push acquia master
	# Sync local files with stage remote.
	rsync -rtcpWzP /var/www/your_site/files/release/   your_acquia_subscription.test@staging-XXXXX.prod.hosting.acquia.com:/var/www/html/your_site/files/release
	# Get latest my-manual-* tag name.
	LATEST_TAG="$(git describe --match my-manual-* --tags $(git rev-list --tags --max-count=1))"
	# Get tag numeric part.
	LATEST_TAG_NUMBER="${LATEST_TAG//[!0-9]}"
	# Get new tag number.
	NEW_TAG_NUMBER=$((LATEST_TAG_NUMBER+1))
	# Create new tag.
	git tag -a my-manual-${NEW_TAG_NUMBER} -m "New generated my-manual-${NEW_TAG_NUMBER} tag"
	# Push newly generated tag to acquia remote.
	git push acquia my-manual-${NEW_TAG_NUMBER}
	# Switch acquia stage to new tag.
	curl -u your_email:my_secret_acquia_key -X POST https://cloudapi.acquia.com/v1/sites/prod:your_acquia_subscription/envs/test/code-deploy.json?path=tags%2Fmy-manual-${NEW_TAG_NUMBER}
	# Use test drush alias.
	drush use @he.test
	# Clear stage code.
	drush cc all
	# Clear stage varnish cache for domains.
	curl -u your_email:my_secret_acquia_key -X DELETE https://cloudapi.acquia.com/v1/sites/prod:your_acquia_subscription/envs/test/domains/your_acquia_domain_to_purge/cache.json
	curl -u your_email:my_secret_acquia_key -X DELETE https://cloudapi.acquia.com/v1/sites/prod:your_acquia_subscription/envs/test/domains/your_acquia_domain_to_purge/cache.json 

fi