File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -54,14 +54,27 @@ jobs:
54
54
run : |
55
55
scp -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ./dist.tar.gz ${{ secrets.EC2_USER }}@${{ secrets.EC2_IP }}:/home/ec2-user/
56
56
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_IP }} << 'EOF'
57
- pm2 start --name app "npx serve -s -l 3000"
58
57
set -e
58
+
59
+ # Stop the running PM2 app
60
+ pm2 stop app
61
+
62
+ # Navigate to the home directory and prepare the deployment
59
63
cd /home/ec2-user
60
64
sudo rm -rf /var/www/vite-app
61
65
sudo mkdir -p /var/www/vite-app
66
+
67
+ # Move and extract the new build
62
68
sudo mv dist.tar.gz /var/www/vite-app/
63
69
cd /var/www/vite-app
64
70
sudo tar -xzvf dist.tar.gz
71
+
72
+ # Set the correct permissions
65
73
sudo chown -R nginx:nginx /var/www/vite-app
74
+
75
+ # Restart Nginx to serve the new build
66
76
sudo systemctl restart nginx
77
+
78
+ # Start the PM2 app with the updated content
79
+ pm2 start --name app "npx serve -s -l 3000"
67
80
EOF
You can’t perform that action at this time.
0 commit comments