-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path900-deploy-github
executable file
·72 lines (58 loc) · 1.48 KB
/
900-deploy-github
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Interactive script which sets up a GitHub repo
source common
INIT status "GitHub Deployment"
echo
echo " 1. Press enter (with no input) to NOT clone any GitHub repo"
echo " 2. Enter the GitHub URL of a repo to clone into a directory"
echo
echo "The GitHub URL is the full URL of the repo and NOT the SSH deployment URL. e.g.:"
echo
echo " https://github.com/MomsFriendlyDevCo/Repo"
echo
echo
read -p "GitHub URL [enter to skip] >" URL
echo
if [ -z "$URL" ]; then
INIT skip "Skipping GitHub deployment"
exit 0
fi
HOSTNAME=`hostname`
PUBKEY=`cat ~/.ssh/id_rsa.pub`
SSHURL=`echo "$URL" | perl -pe 's/^https?:\/\/github\.com\/(.*)$/git\@github.com:\1.git/g'`
REPO=`echo "$URL" | perl -pe 's/.+\/(.*?)$/\1/'`
echo
echo "Visit $URL/settings/keys"
echo
echo "Add the following public key:"
echo
echo "Title: $HOSTNAME"
echo
echo "Key:"
echo "$PUBKEY"
echo
echo
read -p "Press enter when ready or Ctrl+C to abort"
echo
INIT status "Cloning GitHub repo"
cd
git clone "$SSHURL"
cd "$REPO"
INIT status "Installing project NPM dependencies"
npm install
INIT status "Installing bower dependencies"
bower install --allow-root
if [ -e 'gulpfile.js' ]; then
INIT status "Initial Gulp build"
gulp build
INIT status "Building initial database"
gulp db
fi
if [ -e 'gulp-tasks/deploy.js' ]; then
INIT status "Executing deployment"
gulp deploy
echo
echo "Use \"pm2 logs\" to see logs in future"
fi
INIT status "Add NODE_SITE_DIR environment variable"
echo "export NODE_SITE_DIR='$REPO'" >>~/.bashrc