-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdokyll.sh
executable file
·140 lines (121 loc) · 3.56 KB
/
dokyll.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
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh
multiconfig='--config _config.yml,_local_config.yml'
prodconfig='--config _codeberg_config.yml'
md="$(dirname "$(readlink -f "$0")")"
cachedir="$md/_bundle"
dokyll() {
docker run --rm \
-v "$md:/mnt" \
-v "$cachedir:/usr/local/bundle" \
$DOKYLL_PRE \
registry.gitlab.com/polettix/dokyll \
"$@"
}
command="${1:-""}"
[ $# -gt 0 ] && shift
case "$command" in
(bundle)
dokyll bundle "$@"
exit $?
;;
(bundle-update)
DOKYLL_PRE='' dokyll bundle update --all
exit $?
;;
(cache)
rm -rf "$cachedir"
mkdir -p "$cachedir"
DOKYLL_PRE='' dokyll bundle install
exit $?
;;
(one-build|build-one)
DOKYLL_PRE='' dokyll bundle exec jekyll build \
$multiconfig --future
exit $?
;;
(build)
DOKYLL_PRE='' dokyll bundle exec jekyll build \
$multiconfig --watch --future
exit $?
;;
(cqbuild)
cd _codeberg &&
git checkout wavefront &&
cd .. &&
DOKYLL_PRE='' dokyll bundle exec jekyll build --future \
$prodconfig "$@"
;;
(cbuild)
cd _codeberg &&
git checkout wavefront &&
cd .. &&
DOKYLL_PRE='' dokyll bundle exec jekyll build $prodconfig "$@" &&
cd _codeberg &&
msg="$(git status --short --branch | sed -ne '/^??/{s/.* //;s#/$##;s#/#-#g;p}')" &&
git add . &&
git commit -m "Publish $msg"
;;
(cpush)
branch="$(git rev-parse --abbrev-ref HEAD)" &&
[ "$branch" = 'wavefront' ] &&
count="$(git rev-list --count pages..wavefront)" &&
[ "$count" -eq 1 ] &&
msg="$(git log --pretty=format:%s -1)" &&
git checkout pages &&
git merge wavefront &&
git reset --soft pages-root &&
git commit -m "$msg" &&
git branch --force wavefront &&
git push --force
;;
(cpublish)
cd _codeberg &&
git checkout pages &&
branch="$(git rev-parse --abbrev-ref HEAD)" &&
[ "$branch" = 'pages' ] &&
cd .. &&
DOKYLL_PRE='' dokyll bundle exec jekyll build $prodconfig "$@" &&
cd _codeberg &&
defmsg="Publish $(git status --short --branch \
| sed -ne '/^??/{s/.* //;s#/$##;s#/#-#g;p;q}')" &&
msg="${MSG:-"$defmsg"}"
git add . &&
git reset --soft pages-base &&
git commit -m "$msg" &&
git branch --force wavefront &&
git push --force codeberg pages
;;
(qbuild)
DOKYLL_PRE='' dokyll bundle exec jekyll build \
$multiconfig --watch --future --limit_posts 7
exit $?
;;
(serve)
DOKYLL_PRE='-p 4000:4000' dokyll bundle exec jekyll serve \
$multiconfig --no-watch --skip-initial-build --host=0.0.0.0
exit $?
;;
(build-production|production-build)
cd _codeberg &&
git checkout wavefront &&
cd .. &&
DOKYLL_PRE='' dokyll bundle exec jekyll build \
$prodconfig "$@" &&
cd _codeberg &&
tag="c$(git status --short --branch | sed -ne '/^??/{s/.* //;s#/$##;s#/#-#g;p}')" &&
git add . &&
git commit -m "Publish $tag"
;;
(*)
cat <<EOF
"$0" [cache|build|serve)
bundle-update: run bundle update --all (might solve some issues)
cache: create _bundle cache (only needed once)
build: continuously build site as changes arise (full rebuild every time)
production-build: build site (once) for production in _codeberg
qbuild: continuously build site as changes arise (last 10 posts only)
serve: serve built site
EOF
exit 1;
;;
esac