From 951033576eea60ebd6b6b7ae31d329b6c135e4b8 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Thu, 30 Apr 2026 10:44:16 +0800 Subject: [PATCH] fix(drone): update deployment script for environment variable handling and PM2 commands - Set the HOME environment variable to /root to prevent path expansion issues for npm and bun. - Replaced the previous PM2 command handling with direct commands to streamline the application lifecycle management for nuxt4-demo. - Sourced nvm to ensure the correct Node.js version is used during deployment. These changes enhance the reliability of the deployment process by improving environment configuration and command execution. --- .drone.yml | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/.drone.yml b/.drone.yml index 049a088..b8cf752 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,6 +13,8 @@ trigger: steps: - name: deploy environment: + # exec runner 常不设置 HOME,会导致 ~/.bun、~/.nvm 等路径展开错误 + HOME: /root DEPLOY_BRANCH: deploy REPO_DIR: /root/projects/nuxt4-demo/nuxt4-demo-origin # Gitea 必须用 git 用户拉代码;用 root@ 可能 SSH 能过但 git 会话卡住 @@ -70,22 +72,8 @@ steps: - | set -e cd "$UNZIP_DIR" - # exec runner 常缺登录 PATH,补 npm 全局 bin(pm2 多装在这里) - if command -v npm >/dev/null 2>&1; then - _pfx="$(npm config get prefix 2>/dev/null || true)" - case "$_pfx" in /*) export PATH="${_pfx}/bin:${PATH}" ;; esac - fi - export PATH="${HOME}/.bun/bin:/usr/local/bin:/usr/bin:${PATH}" - run_pm2() { - if command -v pm2 >/dev/null 2>&1; then - command pm2 "$@" - elif command -v npx >/dev/null 2>&1; then - npx --yes pm2 "$@" - else - echo "未找到 pm2 且没有 npx,请在 Runner 上执行: npm i -g pm2" - exit 1 - fi - } - run_pm2 stop nuxt4-demo || true - run_pm2 delete nuxt4-demo || true - run_pm2 start ./run.sh --name nuxt4-demo \ No newline at end of file + source ~/.nvm/nvm.sh + nvm use 24.15.0 + 'pm2 stop nuxt4-demo || true' + 'pm2 delete nuxt4-demo || true' + 'pm2 start ./run.sh --name nuxt4-demo' \ No newline at end of file