-
Notifications
You must be signed in to change notification settings - Fork 16
55 lines (45 loc) · 1.43 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Koders Portfolio App
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16.14.0
- name: Install dependencies
run: npm install --production
- name: Build React app
run: npm run build
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Debug build directory contents
run: ls -R .
- name: Copy build to VPS via SSH
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
password: ${{ secrets.REMOTE_PASSWORD }}
source: "build/"
target: /root/portfolio/
- name: SSH into VPS and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
password: ${{ secrets.REMOTE_PASSWORD }}
script: |
cd /root/portfolio
docker rm $(docker stop $(docker ps -a -q --filter ancestor=koders-website-v5 --format="{{.ID}}"))
docker rmi koders-website-v5
docker build . -t koders-website-v5
docker run -d -p 8081:3000 --name koders-website-v5 -e ${{ secrets.WEBHOOK_URL }} koders-website-v5