-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
73 lines (53 loc) · 1.57 KB
/
build.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
#!/bin/sh
set -e
cd "$(dirname "$0")"
# env
load_env_file() {
ENV_FILE_PATH="$1"
if [ -f "$ENV_FILE_PATH" ]; then
. "$(pwd)/$ENV_FILE_PATH"
fi
}
load_env_file .env
if [ "$NODE_ENV" = "production" ]; then
load_env_file .env.production
load_env_file .env.prod
else
load_env_file .env.development
load_env_file .env.dev
fi
load_env_file .env.local
if [ "$NODE_ENV" = "production" ]; then
load_env_file .env.local.prod
load_env_file .env.local.production
load_env_file .env.prod.local
load_env_file .env.production.local
else
load_env_file .env.local.dev
load_env_file .env.local.development
load_env_file .env.dev.local
load_env_file .env.development.local
fi
# clean previous build and prepare current build
rm -rf out
cp -r template out
(cd out && npm i)
rm -rf articles
rm -rf theme
# build articles
git clone --recursive "${ARTICLES_GIT_REPOSITORY_URL:?}" articles
(cd articles && sh build.sh)
cp -r articles/out out/src/app/_articles
[ ! -d out/src/app/_articles/public ] || mv out/src/app/_articles/public out/public/posts
[ ! -f out/src/app/_theme/init.sh ] || (cd out && sh src/app/_articles/init.sh)
# build theme
git clone --recursive "${THEME_GIT_REPOSITORY_URL:?}" theme
(cd theme && sh build.sh)
cp -r theme/out out/src/app/_theme
[ ! -d out/src/app/_theme/public ] || mv out/src/app/_theme/public out/public/theme
[ ! -f out/src/app/_theme/init.sh ] || (cd out && sh src/app/_theme/init.sh)
# build
MJY_BLOG_DATA_PATH="$(pwd)/out/src/app/_articles/index.json" npm run build
(cd out && npx next build)
# for github pages
touch out/out/.nojekyll