-
Notifications
You must be signed in to change notification settings - Fork 0
34 lines (27 loc) · 822 Bytes
/
auto.yaml
File metadata and controls
34 lines (27 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Deploy to EC2
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER || 'ubuntu' }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /home/ubuntu/FS-cicd
git pull origin main
cd ./backend
npm install --production
cd /home/ubuntu/FS-cicd/frontend
npm install --production
npm run build
sudo rm -rf /var/www/html/*
sudo cp -r /home/ubuntu/FS-cicd/frontend/build/* /var/www/html/
sudo systemctl stop my-node-service.service
sudo systemctl start my-node-service.service