Created
July 30, 2014 12:20
-
-
Save tormjens/458d10e6a50608417629 to your computer and use it in GitHub Desktop.
Git + dploy
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 | |
ACTION="$1" | |
PARONE="$2" | |
PARTWO="$3" | |
PARTHREE="$4" | |
PARFOUR="$5" | |
PARFIVE="$6" | |
PARSIX="$7" | |
GIT="/usr/bin/git" | |
DPLOY="/usr/local/bin/dploy" | |
if [ "$ACTION" == "init" ] || [ "$ACTION" == "commit" ]; then | |
if [ ! -f "$DPLOY" ] || [ ! -f "$GIT" ]; then | |
echo "dploy or git missing. Aborting..." | |
exit | |
fi | |
fi | |
# init action | |
if [ "$ACTION" == "init" ]; then | |
REPO="$PARONE" | |
if [ -z "$REPO" ]; then | |
echo "No repository supplied, so no source or deployment will be added." | |
else #proceed adding repo | |
echo "Initializing git..." | |
$GIT init . | |
echo "Adding remote to git repository..." | |
$GIT remote add origin $REPO | |
echo "Adding dploy..." | |
$DPLOY install | |
FTP_HOST="$PARTWO" | |
FTP_USER="$PARTHREE" | |
FTP_PASS="$PARFOUR" | |
FTP_PATH="$PARFIVE" | |
FTP_SCHEME="$PARSIX" | |
DPLOY_FILE="dploy.yaml" | |
cat /dev/null > $DPLOY_FILE | |
cat <<EOM >$DPLOY_FILE | |
production: | |
scheme: "$FTP_SCHEME" | |
host: "$FTP_HOST" | |
user: "$FTP_USER" | |
pass: "$FTP_PASS" | |
path: | |
local: "/" | |
remote: "$FTP_PATH" | |
exclude: [ "dploy.yaml", "dploy/*.yaml", "deploy/*.json", "deploy/path/**/*.js", "deploy/**/*.md"] | |
EOM | |
$GIT add . --all | |
$GIT commit -m "setup git + dploy" | |
$GIT push origin master | |
fi #end input check | |
# commit action | |
elif [ "$ACTION" == "commit" ]; then | |
$GIT add -A . | |
$GIT commit -m "$PARONE" | |
$GIT push origin master | |
dploy | |
else | |
echo "" | |
echo "" | |
echo "SmartGit 1.0" | |
echo "-----" | |
echo "" | |
echo "Initializes a git repo and makes dploy ready for action" | |
echo "Requires: dploy (get via npm)" | |
echo "" | |
echo "Initialize:" | |
echo "smartgit init REPOSITORY FTPHOST FTPUSER FTPPASSWORD FTPPATH FTPSCHEME" | |
echo "" | |
echo "Commit:" | |
echo 'smartgit commit "My commit message"' | |
echo "" | |
echo "" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment