Skip to content

Instantly share code, notes, and snippets.

@rajasegar
Created October 8, 2018 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajasegar/9a64eac7ddf761a959d517bbe7a35ed3 to your computer and use it in GitHub Desktop.
Save rajasegar/9a64eac7ddf761a959d517bbe7a35ed3 to your computer and use it in GitHub Desktop.
Publish demo app to gh-pages
#!/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