~exprez135/taliaferro

ref: 916d474da632854f52b75fc1443d4177322044ea taliaferro/deploy-beta.sh -rwxr-xr-x 3.5 KiB
916d474d — Nate Resizing census image: rebuilding site Sat Apr 11 18:49:20 CDT 2020. 10 months ago
                                                                                
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
74
#! /bin/bash

# This is a script which, when run on Mac or Linux, will automatically build the site, the index, commit and push it to SoureHut.

# The following creates variables which set the colour/formatting of the output to the terminal.
# Examples: Green is green, under is underlined, bu is bold and underlined, reset resets everything to normal.
green=$(tput setaf 2)
red=$(tput setaf 1)
yellow=$(tput setaf 3)
cyan=$(tput setaf 6)
bold=$(tput bold)
under=$(tput smul)
bu=$(tput bold && tput smul)
reset=$(tput sgr0)

echo "Creating pandoc files..."
cd content/coronavirus
pandoc index.md -f markdown+lists_without_preceding_blankline+hard_line_breaks+blank_before_blockquote -t pdf -o post.pdf --toc -V geometry:"top=2cm, bottom=1.5cm, left=2cm, right=2cm"
pandoc index.md -f markdown+lists_without_preceding_blankline+hard_line_breaks -t docx -o post.docx --toc -s
pandoc index.md -f markdown+lists_without_preceding_blankline+hard_line_breaks -t epub -o post.epub --toc -s
pandoc index.md -f markdown+lists_without_preceding_blankline+hard_line_breaks -t plain -o post.txt --toc -s
pandoc index.md -f markdown+lists_without_preceding_blankline+hard_line_breaks -t rtf -o post.rtf --toc -s
pandoc index.md -f markdown+lists_without_preceding_blankline+hard_line_breaks -t odt -o post.odt --toc -s
cd ../..

echo -e "${bold}Deploying updates to SourceHut...${reset}"

# Build index for site using the generate.sh script (see file for more info).
echo -e "${cyan}Starting index building process...${reset}"
./generate.sh
echo -e "${green}Index build complete.${reset}"

# Build the project using Hugo.
echo -e "${cyan}Starting Hugo build process...${reset}"
hugo -d public_html --minify
echo -e "${green}Hugo build process complete.${reset}"

# Add changes to git for all directories.
echo -e "${cyan}Tracking all git files...${reset}"
git add .

# Commit changes.
echo -e "${cyan}What is the custom commit message?${reset}"
read -r usrmsg

echo -e "${cyan}Committing changes...${reset}"
msg="rebuilding site $(date)."
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$usrmsg: $msg"
echo -e "${green}Changes committed.${reset}"

# Push source and build repos.
echo -e "${cyan}Pushing origin master...${reset}"
git push origin themed
echo -e "${green}Pushed.${reset}"

echo -e "${green}LOCAL PROCESS COMPLETED.${reset}"

# Try to update website on server by SSHing in.
# First, cd (move) to the taliaferro directory.
# Then, git pull the repository (which has now been updated).
# Now, cd (move) into the now-updated public_html folder on the server.
# Then, cp (copy) files from that folder to ~/public_html/, which is the directory which has the contents of the site shown to visitors.
# Finally, exit SSH and tell the user everything is done :).
echo -e "${bold}Attempting to begin remote server update. Beginning SSH connection...${reset}"

ssh taliaferro 'echo -e "SSH process complete."; echo -e "Deploying updates to Server..."; echo -e "Moving into taliaferro folder..."; cd ~/taliaferro-beta; echo -e "Git pulling master..."; git pull origin themed; echo -e "Pulled."; echo -e "Moving back to ~..."; cd ~/; echo -e "Using unison to copy files from git into ~/public_html..."; ./bin/unison public -batch; echo -e "Copying complete."; echo -e "REMOTE PROCESS COMPLETE."; echo -e "Exiting SSH..."; exit'

# This moves back into the <root> directory of the repository. Change it for your system.
cd ~/Documents/source-hut/taliaferro || exit

echo -e "${green}GIT UPDATED. WEBSITE SERVER UPDATED. ALL PROCESSES COMPLETE. CONGRATULATIONS!${reset}"