diff --git a/build-files/.drone.yml b/build-files/.drone.yml index 219e8d3..d0303cf 100644 --- a/build-files/.drone.yml +++ b/build-files/.drone.yml @@ -1,6 +1,8 @@ kind: pipeline type: exec name: deploy +clone: + disable: true trigger: branch: @@ -11,6 +13,8 @@ trigger: steps: - name: deploy environment: + DEPLOY_SSH_KEY: + from_secret: DEPLOY_SSH_KEY DATABASE_URL: from_secret: DATABASE_URL STATIC_DIR: @@ -25,7 +29,15 @@ steps: from_secret: BOOTSTRAP_ADMIN_PASSWORD commands: - 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 delete nuxt4-demo || true"' - 'bash -lc "cd $HOME/projects/nuxt4-demo/nuxt4-demo && pm2 start ./run.sh --name nuxt4-demo"' \ No newline at end of file