当前版本

现在使用 Drone 进行持续集成,配置文件如下

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
kind: pipeline
type: ssh
name: deploy

clone:
depth: 1

server:
host: println.org
user: root
password:
from_secret: password

steps:
- name: build
environment:
PATH: "$$PATH:/opt/node-v14.3.0-linux-x64/bin/"
commands:
- yarn
- yarn build
- mv config/robots.txt public/robots.txt

- name: deploy
commands:
- rm -rf /var/www/*
- mv public/* /var/www/
- chmod -R 777 /var/www/
- echo Done!

历史版本

GIT 钩子

1
ssh deploy@println.org "~/deploy.sh"

部署脚本 deploy.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
#!/usr/bin/env bash

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"

# 根目录
root="/opt/println.org"
# 当前版本
current="${root}/$(date "+%y%m%d-%H%M%S")"

function checkRoot() {
[[ ! -d $1 ]] && mkdir $1
[[ ! -f "$1/deploy.sh" ]] && touch "$1/deploy.sh"
}

function install() {
git clone git@git.println.org:println.fun/alex-tech.git $1
cd $1
yarn && yarn build
mv config/robots.txt public/robots.txt
mv config/deploy.sh ${root}
chmod -R 755 $1
}

function deploy() {
install $1
ln -snf $1 "${root}/current"
# 删除3天前的版本
rm -rf "${root}/$(date -d "+3 day ago" "+%y%m%d")-*"
}

checkRoot ${root}
deploy ${current}

echo -e "https://println.org deploy done!"

[1] Alex.如何使用 drone 进行持续集成