Skip to content

Commit

Permalink
fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
val213 committed Sep 26, 2024
1 parent 5329483 commit 81802db
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/deploy-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,20 @@ jobs:
run: |
cd frontend
npm install
- name: Build Nuxt frontend
run: |
cd frontend
npm run build
- name: List build directory (for debugging)
run: |
ls -la frontend/.output
- name: Compress build artifacts
run: |
cd frontend
tar -czf nuxt-build.tar.gz .output
- name: List compressed file (for debugging)
run: |
ls -la frontend/nuxt-build.tar.gz
- name: Upload Nuxt build artifacts
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -80,8 +75,7 @@ jobs:
echo "$SSH_PASSWORD" | sudo -S chmod -R 755 /usr/share/nginx/html/ibminscut &&
rm /tmp/nuxt-build.tar.gz &&
cd /usr/share/nginx/html/ibminscut/.output/server &&
if [ ! -f package.json ]; then echo "package.json not found"; exit 1; fi &&
sudo env "PATH=$PATH" npm install --production &&
sudo env "PATH=$PATH" pm2 restart nuxt-app || sudo env "PATH=$PATH" pm2 start npm --name "nuxt-app" -- run start
echo "$SSH_PASSWORD" | sudo -S npm install --production &&
pm2 restart nuxt-app || pm2 start npm --name "nuxt-app" -- run start
' || { echo 'SSH command failed'; exit 1; }
rm deploy_key
38 changes: 38 additions & 0 deletions frontend/ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
/**
* Application configuration section
* https://pm2.keymetrics.io/docs/usage/application-declaration/
*/
apps: [
{
name: 'my-nuxt-app', // 应用名称
script: 'nuxt.js', // 启动脚本,对于 Nuxt.js 通常是 nuxt.js 或 nuxt-ts (如果使用 TypeScript)
args: 'start', // 传递给脚本的参数,通常是启动命令
instances: 1, // 启动的实例数量
autorestart: true, // 当应用崩溃时自动重启
watch: false, // 是否监视文件变化并自动重启应用(通常在开发模式下使用)
max_memory_restart: '1G', // 当内存使用超过这个值时重启应用
env: {
NODE_ENV: 'production' // 设置环境变量
},
env_production: {
NODE_ENV: 'production'
}
}
],

/**
* Deployment section
* https://pm2.keymetrics.io/docs/usage/deployment/
*/
deploy: {
production: {
user: 'username', // SSH 用户名
host: 'hostname', // SSH 主机名或 IP 地址
ref: 'origin/main', // Git 仓库的分支
repo: '[email protected]:val213/IBMinSCUT.git', // Git 仓库的 URL
path: '/var/www/app', // 远程服务器上的部署路径
'post-deploy': 'npm install && pm2 startOrReload ecosystem.config.js --env production' // 部署后执行的命令
}
}
};

0 comments on commit 81802db

Please sign in to comment.