Browse Source

fix(drone): update deployment configuration for SSH handling and branch trigger

- Disabled the cloning step to optimize the deployment process.
- Changed the trigger branch from 'deploy-branch' to 'deploy' for better alignment with deployment strategy.
- Refactored environment variables to focus on SSH key management, enhancing security during deployment.
- Added commands for setting up SSH keys and known hosts, improving connection reliability.

These changes streamline the deployment workflow and enhance security measures in the CI/CD pipeline.
main
npmrun 1 week ago
parent
commit
ecf81e87be
  1. 14
      build-files/.drone.yml

14
build-files/.drone.yml

@ -1,6 +1,8 @@
kind: pipeline kind: pipeline
type: exec type: exec
name: deploy name: deploy
clone:
disable: true
trigger: trigger:
branch: branch:
@ -11,6 +13,8 @@ trigger:
steps: steps:
- name: deploy - name: deploy
environment: environment:
DEPLOY_SSH_KEY:
from_secret: DEPLOY_SSH_KEY
DATABASE_URL: DATABASE_URL:
from_secret: DATABASE_URL from_secret: DATABASE_URL
STATIC_DIR: STATIC_DIR:
@ -25,7 +29,15 @@ steps:
from_secret: BOOTSTRAP_ADMIN_PASSWORD from_secret: BOOTSTRAP_ADMIN_PASSWORD
commands: commands:
- export HOME=/root - export HOME=/root
- 'REPO_DIR="$HOME/projects/nuxt4-demo/nuxt4-demo"; SRC_DIR="$(pwd)"; rm -rf "$REPO_DIR"; mkdir -p "$(dirname "$REPO_DIR")"; cp -a "$SRC_DIR" "$REPO_DIR"' - mkdir -p "$HOME/.ssh"
- chmod 700 "$HOME/.ssh"
- 'printf "%s\n" "$DEPLOY_SSH_KEY" > "$HOME/.ssh/id_rsa"'
- chmod 600 "$HOME/.ssh/id_rsa"
- 'ssh-keyscan -p 8892 -H git.xieyaxin.top >> "$HOME/.ssh/known_hosts"'
- chmod 644 "$HOME/.ssh/known_hosts"
- 'export SSH_OPTS="-i $HOME/.ssh/id_rsa -o IdentitiesOnly=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts -o StrictHostKeyChecking=accept-new -o BatchMode=yes -o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=3"'
- 'ssh $SSH_OPTS -T -p 8892 root@git.xieyaxin.top || true'
- 'REPO_DIR="$HOME/projects/nuxt4-demo/nuxt4-demo"; if [ -d "$REPO_DIR/.git" ]; then GIT_SSH_COMMAND="ssh $SSH_OPTS" git -C "$REPO_DIR" fetch origin deploy-branch && git -C "$REPO_DIR" checkout -B deploy-branch origin/deploy-branch; else rm -rf "$REPO_DIR" && mkdir -p "$(dirname "$REPO_DIR")" && GIT_SSH_COMMAND="ssh $SSH_OPTS" git clone --depth 1 -b deploy-branch "ssh://root@git.xieyaxin.top:8892/topuser/nuxt4-demo.git" "$REPO_DIR"; fi'
- 'bash -lc "cd $HOME/projects/nuxt4-demo/nuxt4-demo && pm2 stop nuxt4-demo || true"' - 'bash -lc "cd $HOME/projects/nuxt4-demo/nuxt4-demo && pm2 stop nuxt4-demo || true"'
- 'bash -lc "cd $HOME/projects/nuxt4-demo/nuxt4-demo && pm2 delete nuxt4-demo || true"' - 'bash -lc "cd $HOME/projects/nuxt4-demo/nuxt4-demo && pm2 delete nuxt4-demo || true"'
- 'bash -lc "cd $HOME/projects/nuxt4-demo/nuxt4-demo && pm2 start ./run.sh --name nuxt4-demo"' - 'bash -lc "cd $HOME/projects/nuxt4-demo/nuxt4-demo && pm2 start ./run.sh --name nuxt4-demo"'
Loading…
Cancel
Save