forked from mit-acl/mit-acl.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_and_deploy.bash
More file actions
executable file
·42 lines (31 loc) · 1.34 KB
/
build_and_deploy.bash
File metadata and controls
executable file
·42 lines (31 loc) · 1.34 KB
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
#!/usr/bin/env bash
# pull down current master branch of bibliography repo
# https://github.com/mit-acl/bibliography
rm -rf _bibliography bibliography-master
wget -qO- https://github.com/mit-acl/bibliography/archive/refs/heads/master.zip | busybox unzip - && mv bibliography-master/ _bibliography
# ensure _site is up-to-date
git -C _site reset --hard
git -C _site pull
# confirm current build is committed
confirm_commit=$(git status -s | wc -l)
if [ $confirm_commit -ne 0 ]; then
echo "please commit all changes before building and deploying"
exit 1
fi
# TODO confirm _site and _bibliography were cloned correctly
cd docker
GIT_TARGET="-C ../_site"
# update _site directory
git $GIT_TARGET pull -f
# copy in Gemfile to ensure correct dependenies are built into the image
cp ../Gemfile .
# build and run the image
./build.bash && ./run.bash
# check if site has meaningfully changed (i.e. any file besides sitemap.xml's build timestamps have changed), if so add, commit, and push update
# Reference: https://stackoverflow.com/questions/47146064/number-of-modified-files-in-git-index
files_changed=$(git $GIT_TARGET status -s -uno | grep -v sitemap.xml$ | wc -l)
if [ $files_changed -gt 0 ]; then
git $GIT_TARGET add -A && git $GIT_TARGET commit -m "docker build: $(date)" && git $GIT_TARGET push
else
echo "no website content has changed"
fi