-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdeploy.sh
executable file
·79 lines (52 loc) · 1.54 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
#!/bin/bash
# Use the requirejs optimizer r.js to optimise js files
# Will deploy the site the ./docs directory in the current branch.
echo ""
echo "Instructions"
echo "Deploys to the ./docs directory and pushes to git repository"
echo ""
if [ ! -d "./docs" ]; then
mkdir docs
fi
if [ -d tmp ]; then
BUILD_DIR="./tmp"
else
mkdir tmp
BUILD_DIR="./tmp"
fi
rm -rf "$BUILD_DIR"
node cslEditorLib/external/r.js -o build.js dir=$BUILD_DIR
# doing this becuase the cjsTranslate r.js option breaks citeproc.js
ORIGINAL_CITEPROC=$(find cslEditorLib/external/citeproc/citeproc*.js)
BUILD_CITEPROC=$(find $BUILD_DIR/cslEditorLib/external/citeproc/citeproc*.js)
echo "copying $ORIGINAL_CITEPROC to $BUILD_CITEPROC"
cp $ORIGINAL_CITEPROC $BUILD_CITEPROC
# Replace $GIT_COMMIT with the git commit hash in all php files
GIT_COMMIT=$(git rev-parse HEAD)
echo "git commit is $GIT_COMMIT"
cd $BUILD_DIR
find cslEditorLib/pages/*.html >> find */index.html > filesToConvert
while read FILENAME;
do
echo "converting $FILENAME"
sed s/\$GIT_COMMIT/$GIT_COMMIT/g <$FILENAME >tempFile
mv tempFile $FILENAME
done < filesToConvert
rm filesToConvert
# Remove any *.php files in external libraries
find external -name "*.php" -type f -print0 | xargs -0 rm -f
find cslEditorLib/external -name "*.php" -type f -print0 | xargs -0 rm -f
# Run Jekyll
jekyll build
#don't use docs directory in build
rm -rf ./_site/docs
#clean up docs directory
rm -rf ../docs/*
cd ../docs
cp -r ../tmp/_site/* ./
cd ..
# Clean_up
rm -rf "$BUILD_DIR"
git add --all
git commit -m "deploy"
git push