-
Notifications
You must be signed in to change notification settings - Fork 95
/
update.sh
executable file
·56 lines (43 loc) · 1.29 KB
/
update.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
#!/bin/bash
# set -o xtrace
VERSION=$1
PORT=1313
NAME=test-hugo
# set version in Dockerfile
sed -i "s/HUGO_VERSION=[0-9.]\+/HUGO_VERSION=$VERSION/g" Dockerfile
# cleanup container
docker stop "$NAME"
docker rm "$NAME"
rm -rf test-output
# build image
docker build --no-cache=true --pull --tag jojomi/hugo:latest .
# verify image build
docker images | grep jojomi/hugo | grep latest
# run container
mkdir --parents test-output
docker run \
--env HUGO_WATCH=true \
--env HUGO_BASEURL=http://localhost:$PORT \
--name "$NAME" \
--volume "$(pwd)/test-src:/src" \
--volume "$(pwd)/test-output:/output" \
--publish "$PORT:1313" \
--detach \
jojomi/hugo:latest
docker ps | grep "$NAME"
# verify output
xdg-open http://localhost:$PORT > /dev/null
# ask for continuation
read -r -p "Does it work? [y/N] " prompt
# cleanup container
docker stop "$NAME"
docker rm "$NAME"
sudo rm -rf test-output
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]
then
# git: commit, tag, push
git add Dockerfile && git commit -m "version $VERSION" && git tag $VERSION && git push && git push --tags
# open hub.docker.com
xdg-open https://hub.docker.com/r/jojomi/hugo/builds/ > /dev/null
xdg-open https://hub.docker.com/r/jojomi/hugo/~/settings/automated-builds/ > /dev/null
fi