Created
July 9, 2018 18:53
-
-
Save wesleyegberto/8d524874cd09e2f4dd100d0f6b5c23d4 to your computer and use it in GitHub Desktop.
Example of script to automatically stash updates, checkout and merge a branch and then commit the changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit # Exit on error | |
git stash save 'Before deploy' # Stash all changes before deploy | |
git checkout deploy | |
git merge master --no-edit # Merge in the master branch without prompting | |
npm run build # Generate the bundled Javascript and CSS | |
if $(git commit -am Deploy); then # Commit the changes, if any | |
echo 'Changes Committed' | |
fi | |
git push heroku deploy:master # Deploy to Heroku | |
git checkout master # Checkout master again | |
git stash pop # And restore the changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment