Skip to content

Instantly share code, notes, and snippets.

@kamranayub
Created February 26, 2015 16:29
Show Gist options
  • Save kamranayub/ca7b6866ab43771d9da8 to your computer and use it in GitHub Desktop.
Save kamranayub/ca7b6866ab43771d9da8 to your computer and use it in GitHub Desktop.
Deploy site from Travis
#!/bin/bash
echo "Running deployment script..."
CURRENT_COMMIT=`git rev-parse HEAD`
# Change the branch used if applicable (e.g. gh-pages)
echo "Cloning master branch..."
# Hide output since we use an access token here
git clone -b master "https://${GH_TOKEN}@${GH_REF}" _deploy > /dev/null 2>&1 || exit 1
###
# Copy your source files to a deployment directory
echo "Copying built files"
cp -r ./public/* _deploy
###
# Move into deployment directory
cd _deploy
echo "Committing and pushing to GH"
git config user.name "Travis-CI"
git config user.email "[email protected]"
# Commit changes, allowing empty changes (when unchanged)
git add -A
git commit --allow-empty -m "Deploying site for $CURRENT_COMMIT" || exit 1
# Push to branch
git push origin master > /dev/null 2>&1 || exit 1
echo "Pushed deployment successfully"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment