forked from citation-style-language/csl-editor-demo-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·73 lines (55 loc) · 1.78 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
#!/bin/bash
# Use the requirejs optimizer r.js to optimise js files
# By default it will create a sibling build directory called 'csl-build'
# or it uses a command line argument if present
echo ""
echo "Instructions"
echo "Argument 1: the name of the build dir, which must be a"
echo " sibling of the current dir"
echo "Argument 2: the name of the gh-pages dir to deploy to,"
echo " which must be a sibling of the current dir"
echo ""
if [ $# -eq 0 ]
then
echo "Build dir not specified"
exit
else
BUILD_DIR="../$1"
echo "Deploying to build dir: $BUILD_DIR"
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
# If gh-pages repo directory specified, deploy to github
if [ -n "$2" ]
then
cd ../$2
git checkout gh-pages
git rm -rf .
# Copy to gh-pages repo and commit
cp -r $BUILD_DIR/_site/* .
git add --all
git commit -m "deploy"
git push
fi