merged
This commit is contained in:
commit
5251ead1ff
|
|
@ -54,3 +54,60 @@ jobs:
|
||||||
cd frontend && npm run build && cd ..
|
cd frontend && npm run build && cd ..
|
||||||
pm2 restart ecosystem.config.js
|
pm2 restart ecosystem.config.js
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
name: Deploy to Production
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
cd backend && npm install && cd ..
|
||||||
|
cd frontend && npm install && cd ..
|
||||||
|
|
||||||
|
- name: Run backend tests
|
||||||
|
run: |
|
||||||
|
cd backend
|
||||||
|
npm test || echo "No tests configured"
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
run: |
|
||||||
|
cd frontend
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
- name: Deploy to server
|
||||||
|
env:
|
||||||
|
SERVER_HOST: ${{ secrets.SERVER_HOST }}
|
||||||
|
SERVER_USER: ${{ secrets.SERVER_USER }}
|
||||||
|
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
run: |
|
||||||
|
# Setup SSH
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "$SSH_KEY" > ~/.ssh/deploy_key
|
||||||
|
chmod 600 ~/.ssh/deploy_key
|
||||||
|
ssh-keyscan -H $SERVER_HOST >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
# Deploy
|
||||||
|
ssh -i ~/.ssh/deploy_key $SERVER_USER@$SERVER_HOST << 'EOF'
|
||||||
|
cd /var/www/aeroEcho
|
||||||
|
git pull origin main
|
||||||
|
npm run install:all
|
||||||
|
cd frontend && npm run build && cd ..
|
||||||
|
pm2 restart ecosystem.config.js
|
||||||
|
EOF
|
||||||
|
|
|
||||||
1
backend/index.js
Normal file
1
backend/index.js
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// CI/CD test
|
||||||
24
ecosystem.config.js
Normal file
24
ecosystem.config.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
module.exports = {
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
name: 'aeroecho-backend',
|
||||||
|
cwd: './backend',
|
||||||
|
script: 'npm',
|
||||||
|
args: 'start',
|
||||||
|
env: {
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
PORT: 3001
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'aeroecho-frontend',
|
||||||
|
cwd: './frontend',
|
||||||
|
script: 'npm',
|
||||||
|
args: 'start',
|
||||||
|
env: {
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
PORT: 3000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user