Created
October 8, 2018 12:52
-
-
Save rajasegar/9a64eac7ddf761a959d517bbe7a35ed3 to your computer and use it in GitHub Desktop.
Publish demo app to gh-pages
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/sh | |
REPO_NAME=$(sed -n '/name/p' package.json | awk '{print $2}' | sed 's/"//g; s/,//g') | |
DIST_FOLDER=dist | |
# Clean up dist folder | |
rm -Rf $DIST_FOLDER/* | |
# Run the build | |
npm run build | |
# Create a temp directory | |
mkdir /tmp/$REPO_NAME | |
# Copy all the build files to the temp directory | |
cp -R $DIST_FOLDER/* /tmp/$REPO_NAME | |
# Check out the gh-pages branch | |
git checkout gh-pages | |
# Remove all the files in the current branch | |
rm -Rf ./* | |
# Copy all the files from the temp directory | |
cp -R /tmp/$REPO_NAME/* ./ | |
# Commit and push to gh-pages | |
git add . | |
git commit -m "Publishing demo for $(git describe --tags)" | |
git push origin gh-pages | |
# Checkout the master branch | |
git checkout master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment