You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

43 lines
1.2 KiB

kind: pipeline
type: exec
name: deploy
platform:
os: linux
arch: amd64
steps:
- name: build-backend
commands:
- cd backend && CGO_ENABLED=0 go build -ldflags="-s -w" -o short-link-server .
- name: build-frontend
commands:
- cd frontend && npm ci && npm run build
- name: deploy
commands:
# 创建部署目录
- mkdir -p /opt/short-link/frontend
# 拷贝编译产物
- mv /opt/short-link/short-link-server /opt/short-link/short-link-server.bak >/dev/null 2>&1 || true
- cp backend/short-link-server /opt/short-link/short-link-server
- cp -r frontend/dist/* /opt/short-link/frontend/
# 进入部署目录,用 nohup 后台启动服务(先杀死旧进程,避免端口冲突)
- cd /opt/short-link
- pkill -f short-link-server || true
- export DB_PATH=/opt/short-link/data
- export DoMAIN=https://xieyaxin.top:8899
- export ADDR=:8819
- export ADMIN_TOKEN=asdaersfdgfdhtretewfsddfgfdgdsfs
# nohup 启动,日志输出到 nohup.out
- nohup ./short-link-server > nohup.out 2>&1 &
- cd /root
- caddy reload
depends_on:
- build-backend
- build-frontend
trigger:
branch:
- main