-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·75 lines (65 loc) · 2.48 KB
/
deploy.sh
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
73
#!/usr/bin/env bash
CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HOME_PATH=$HOME
GHOST_PATH="${HOME_PATH}/.ghost/current"
SERVER_URL="localhost:2373/"
first_deploy() {
if [ -e "index.html" ]; then
echo "<!DOCTYPE HTML>" >> index.html
echo "<html lang=\"en\">" >> index.html
echo " <head> >>" index.html
echo " <meta charset=\"UTF-8\">" >> index.html
echo " <meta http-equiv=\"refresh\" content=\"1; url=static/index.html\">" >> index.html
echo " <script>window.location.href = \"static/index.html\"; </script> >>" index.html
echo " <title>Page Redirection</title>" >> index.html
echo " </head> >>" index.html
echo "<body> >>" index.html
echo " If you are not redirected automatically, follow the <a href='static/index.html'>link to home page</a>. " >> index.html
echo "</body>" >> index.html
echo "</html>" >> index.html
fi
# Expects an input from user to provide a Git remote URL in which Ghost will be deployed.
echo ' -------------------- INFORMATION NEEDED -------------------- '
echo ''
echo "Following you'll be asked to enter a Git Remote URL in which you would like to deploy Ghost."
echo "Example:"
echo " git@github.com:YOUR_USERNAME/YOUR_REPOSITORY.git"
echo ''
read -p "Remote URL: " remote_url
# Setting up buster on the current folder.
buster setup --gh-repo="$remote_url"
buster generate --domain="$SERVER_URL"
git init
git remote add origin "$remote_url"
# Add .gitignore
if [ -f "gitignore.base" ]; then
$(rm -f .gitignore)
$(cp gitignore.base .gitignore)
fi
git add -A
git commit -m "First commit on Github Pages using Ghost."
git push origin master:master master:gh-pages -f
}
update() {
# Generating static files
buster generate --domain="$SERVER_URL"
# Commiting changes to repository in order to deploy new content.
git add -A
git commit -m "Update on the website at $(date)"
git push origin master:master master:gh-pages -f
}
deploy() {
# Check if repo already exists on current path
repo_exists="$(git status)"
case "fatal" in
*"$repo_exists"*)
echo '[INFO] Configuring git repository...'
echo '[INFO] Generating static files from Ghost server...'
first_deploy
exit
;;
esac
echo '[INFO] Deploying to your Github repository...'
update
}
deploy