66 lines
1.7 KiB
YAML
66 lines
1.7 KiB
YAML
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: deploy
|
|
|
|
node:
|
|
runner: ip165
|
|
|
|
trigger:
|
|
branch:
|
|
- main
|
|
- master
|
|
event:
|
|
- push
|
|
|
|
steps:
|
|
- name: package
|
|
image: docker.1ms.run/library/alpine:3.20
|
|
commands:
|
|
- mkdir -p dist
|
|
- tar czf dist/feishu-approval.tar.gz --exclude=.git --exclude=dist -C . .
|
|
|
|
- name: upload
|
|
image: appleboy/drone-scp
|
|
pull: if-not-exists
|
|
settings:
|
|
host:
|
|
from_secret: deploy_host
|
|
username:
|
|
from_secret: deploy_user
|
|
password:
|
|
from_secret: deploy_password
|
|
port: 22
|
|
target: /tmp
|
|
source:
|
|
- dist/feishu-approval.tar.gz
|
|
strip_components: 1
|
|
overwrite: true
|
|
|
|
- name: deploy
|
|
image: appleboy/drone-ssh
|
|
pull: if-not-exists
|
|
settings:
|
|
host:
|
|
from_secret: deploy_host
|
|
username:
|
|
from_secret: deploy_user
|
|
password:
|
|
from_secret: deploy_password
|
|
port: 22
|
|
script:
|
|
- set -e
|
|
- 'DEPLOY_PATH="/www/wwwroot/node_project"'
|
|
- 'ARCHIVE="/tmp/feishu-approval.tar.gz"'
|
|
- 'APP_NAME="feishu_approval"'
|
|
- 'LEGACY_APP_NAME="feishu-approval"'
|
|
- 'pm2 describe "$APP_NAME" >/dev/null 2>&1 && pm2 stop "$APP_NAME" || true'
|
|
- 'pm2 describe "$LEGACY_APP_NAME" >/dev/null 2>&1 && pm2 stop "$LEGACY_APP_NAME" || true'
|
|
- test -f "$ARCHIVE"
|
|
- mkdir -p "$DEPLOY_PATH"
|
|
- find "$DEPLOY_PATH" -mindepth 1 -delete
|
|
- tar xzf "$ARCHIVE" -C "$DEPLOY_PATH"
|
|
- chmod +x "$DEPLOY_PATH/deploy/start.sh"
|
|
- echo "Deploy OK -> $DEPLOY_PATH"
|
|
- 'pm2 describe "$APP_NAME" >/dev/null 2>&1 && pm2 restart "$APP_NAME" --update-env || pm2 start "$DEPLOY_PATH/server.js" --name "$APP_NAME"'
|