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.
39 lines
1005 B
39 lines
1005 B
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
|
|
# 拷贝编译产物
|
|
- 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
|
|
# nohup 启动,日志输出到 nohup.out
|
|
- nohup ./short-link-server > nohup.out 2>&1 &
|
|
- mv ./Caddyfile ~/projects/_conf/short-link.conf
|
|
- cd ~
|
|
- caddy reload
|
|
depends_on:
|
|
- build-backend
|
|
- build-frontend
|
|
|
|
trigger:
|
|
branch:
|
|
- main
|