-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdeploy.sh
executable file
·129 lines (102 loc) · 3.67 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails
function doCompile {
./compile.sh
}
# Enable case-insensitive pattern matching.
shopt -s nocasematch
get_download_url() {
echo "https://raw.githubusercontent.com/rroohhh/travis-texlive/master/texlive.tar.xz"
}
echo "Downloading portable TeX Live installation..."
curl -s $( get_download_url ) | tar -xJC "${HOME}"
# Ensure PATH points to the platform-specific binaries.
if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then
export PATH="${HOME}/texlive/bin/x86_64-linux:${PATH}"
else
export PATH="${HOME}/texlive/bin/x86_64-darwin:${PATH}"
fi
git clone https://code.orgmode.org/bzg/org-mode.git
cd org-mode
make autoloads
make
sudo make install
cd ..
rm -rf org-mode
# Save some useful information
SHA=`git rev-parse --verify HEAD`
# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone https://github.com/hd-notes/pdfs.git pdfs
git clone --recursive https://github.com/hd-notes/hd-notes.github.io.git pages
# Clean out existing contents
# TODO(robin): auto run fetch scripts
# rm -rf pdfs/**/* || exit 0
rm -rf pages/index.html || exit 0
# Run our compile script
doCompile
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Skipping deploy; just doing a build."
exit 0
fi
# copy the pdfs
find . ! -path "./pdfs/*" ! -path "./pages/*" -name '*.pdf' -exec dirname {} \; | xargs -I {} mkdir -p pdfs/{} 2> /dev/null
find . ! -path "./pdfs/*" ! -path "./pages/*" -name '*.pdf' -exec cp {} pdfs/{} \;
# Now let's go have some fun with the cloned repo
echo "updating pdfs"
cd pdfs
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"
# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
# if [ -z `git diff --exit-code` ]; then
# echo "No changes to the output on this push; exiting."
# exit 0
# fi
# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add .
git commit -m "travis auto compile: ${SHA}"
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
openssl aes-256-cbc -K $encrypted_fcdac90c3348_key -iv $encrypted_fcdac90c3348_iv -in ../keys.enc -out keys -d
head -c3243 keys > pdf_key
tail -c3247 keys > ../pages/pages_key
chmod 600 pdf_key
eval `ssh-agent -s`
ssh-add pdf_key
# Now that we're all set up, we can push.
git push [email protected]:hd-notes/pdfs.git
# git push origin master
cd ..
echo "updating pages"
# sleep a bit to give github some time
sleep 1
cd pages
#cd pdfs
#git pull
#cd ..
# TODO(robin): why does this not work? (maybe git is too old?)
git submodule update --remote --merge
./generate.sh ../
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"
# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
# if [ -z `git diff --exit-code` ]; then
# echo "No changes to the output on this push; exiting."
# exit 0
# fi
# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add .
git commit -m "travis auto update: ${SHA}"
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
# ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
# ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
# ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
# ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
chmod 600 pages_key
ssh-add -D
ssh-add pages_key
# Now that we're all set up, we can push.
git push [email protected]:hd-notes/hd-notes.github.io.git
# git push origin master