Browse Source

fix(drone): improve deployment logic for repository management

- Updated the deployment logic in the Drone configuration to streamline the handling of the repository directory.
- Enhanced the cloning and fetching process to ensure the correct branch is checked out while removing the existing directory if it does not contain a valid git repository.

These changes improve the reliability and efficiency of the CI/CD deployment process.
main
npmrun 1 week ago
parent
commit
28cb956b7a
  1. 2
      .drone.yml

2
.drone.yml

@ -38,7 +38,7 @@ steps:
- 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'
- 'if [ ! -d "$HOME/projects/nuxt4-demo/nuxt4-demo" ]; then mkdir -p "$HOME/projects/nuxt4-demo" && GIT_SSH_COMMAND="ssh $SSH_OPTS" git clone --depth 1 -b deploy-branch "ssh://root@git.xieyaxin.top:8892/topuser/nuxt4-demo.git" "$HOME/projects/nuxt4-demo/nuxt4-demo"; else cd "$HOME/projects/nuxt4-demo/nuxt4-demo" && GIT_SSH_COMMAND="ssh $SSH_OPTS" git pull origin deploy-branch; fi'
- '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 "pm2 stop nuxt4-demo || true"'
- 'bash -lc "pm2 delete nuxt4-demo || true"'
- 'bash -lc "pm2 start ./run.sh --name nuxt4-demo"'
Loading…
Cancel
Save