-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (50 loc) · 1.47 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
56
57
58
name: Deploy React App
on:
push:
branches:
- main # main 브랜치에 푸시될 때 실행
jobs:
deploy:
runs-on: ubuntu-latest # 최신 Ubuntu 버전에서 실행
steps:
# Git 체크아웃
- name: Checkout code
uses: actions/checkout@v2
# Node.js 버전 설정
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
# node_modules 캐시
- name: Cache node_modules
uses: actions/cache@v2
with:
path: ./node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
# 의존성 설치 및 빌드
- name: Install dependencies and build
run: |
npm install
npm run build
# 빌드 파일을 서버로 전송
- name: Copy build directory to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
source: "./dist/*"
target: "/var/www/html/dist"
# 원격 서버에서 Nginx 재시작
- name: Restart Nginx on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
sudo service nginx restart