-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
46 lines (44 loc) · 1.69 KB
/
.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
44
45
46
sync_github:
image: node:12
only:
- master
script:
- rm -rf .git
- git init
- git config --global user.email "[email protected]"
- git config --global user.name "KwokRonny"
- git config --global credential.helper store
- git remote add origin "https://${GITHUB_TOKEN}:[email protected]/kwokronny/yoz-comment.git"
- git add .
- git commit -m "镜像仓库同步 ${CI_JOB_ID}"
- git push --force -u origin master
generate:
image: golang:1.15-alpine
only:
- release-blog
variables:
deploy_path: "/www/wwwroot/kwokronny.top/yoz-comment/"
tar_name: "yoz-comment.release.tar.gz"
before_script:
- sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
- apk update
- apk add --update openssh-client nodejs npm
- mkdir -p ~/.ssh
- echo "$SERVER_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval $(ssh-agent -s)
- ssh-add ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- npm install cnpm --registry=https://registry.npm.taobao.org/ -g
- cnpm install parcel-bundler -g
- cnpm install
- npm run build
- mkdir statics
- go env -w GOPROXY=https://goproxy.io,direct
- npm run bindata-install
- npm run bindata
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o comment-app main.go
- tar -zcvf "$tar_name" comment-app
- scp -P"$SERVER_PORT" -r "$tar_name" root@"$SERVER_HOST":/root
- ssh -p"$SERVER_PORT" root@"$SERVER_HOST" "pkill -9 comment-app && mkdir ${deploy_path}; tar -zxvf $tar_name -C $deploy_path && cd $deploy_path && nohup ./comment-app > /dev/null 2>&1 &"