-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
43 lines (35 loc) · 965 Bytes
/
.gitlab-ci.yml
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
# 自托管方式
variables:
GIT_SUBMODULE_STRATEGY: recursive
CLOUDFLARE_API_TOKEN: $CLOUDFLARE_API_TOKEN
image: registry.gitlab.com/pages/hugo/hugo_extended:latest
stages:
- deploy
before_script: |
apk update
apk add --no-cache bash npm
npm install -g wrangler@latest
hugo --minify
deploy:
stage: deploy
script: |
PUBLISH_DIR="$(grep publishDir config.toml | awk -F '\"' '{print $2}')" # static files
if [[ -z "$PUBLISH_DIR" ]]; then
echo "Not found publishDir in config.toml"
exit 1
fi
BRANCH_NAME="main"
if [[ "$CI_COMMIT_BRANCH" == "main" ]]; then
PROJECT_NAME="nav"
elif [[ "$CI_COMMIT_BRANCH" == "more" ]]; then
PROJECT_NAME="navs"
else
echo "the branch ${CI_COMMIT_BRANCH} is not main or more"
exit 1
fi
echo -e "no\n" | wrangler pages deploy "$PUBLISH_DIR" \
--project-name "$PROJECT_NAME" \
--branch "$BRANCH_NAME"
only:
- main
- more