-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (38 loc) · 1.2 KB
/
actions-ec2.yml
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
35
36
37
38
39
40
name: Push-to-EC2
# Trigger deployment only on push to main branch
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy to EC2 on main branch push
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout the files
uses: actions/checkout@v3
- name: Deploy to my EC2
uses: appleboy/ssh-action@master
env:
TARGETDIR: app-store-dash
with:
host: ${{ secrets.HOST_DNS }}
username: ${{ vars.USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
envs: TARGETDIR
script_stop: true
script: |
cd $TARGETDIR
pwd
git pull origin main
cd frontend
sudo systemctl enable /home/ubuntu/app-store-dash/scripts/app-store-api.service
sudo systemctl enable /home/ubuntu/app-store-dash/scripts/app-store-frontend.service
sudo systemctl daemon-reload
sudo systemctl restart app-store-api
npm run build
sudo rm /run/app-store-frontend.sock
sudo systemctl restart app-store-frontend
sudo chown -R www-data:www-data /tmp/app-store-frontend.sock