-
Notifications
You must be signed in to change notification settings - Fork 3
84 lines (81 loc) · 2.45 KB
/
cicd.yaml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: CI/CD
on: [push]
jobs:
CI:
runs-on: ubuntu-latest
steps:
- name: 타임존 설정
uses: szenius/[email protected]
with:
timezoneLinux: "Asia/Seoul"
- name: 체크아웃
uses: actions/checkout@v3
- name: Node.js 16.x Version
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: 종속 모듈들 캐싱
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/node_modules
key: npm-packages-${{ hashFiles('**/package-lock.json') }}
id: cache
- name: 종속 모듈들 설치
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
- name: lint 체크
run: npm run lint
- name: 빌드 체크
run: npm run build
- name: 단위 테스트 체크
run: npm run test
- name: 통합 테스트 체크
run: npm run test:e2e
CD-develop:
name: deploy-develop
runs-on: ubuntu-latest
needs: CI
if: ${{ github.ref == 'refs/heads/develop' }}
steps:
- name: 리모트 쉘 접속
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_DEVELOP_HOST }}
username: ${{ secrets.EC2_DEVELOP_USER }}
key: ${{ secrets.EC2_DEVELOP_SSH_KEY }}
script: |
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
echo "해당 리포지토리로 이동"
cd $HOME/24-not-enough
echo "리포지토리 pull"
git pull origin develop
echo "앱 빌드"
npm install
npm run build
echo "앱 배포 (reload)"
pm2 reload 24-not-enough
CD-main:
name: deploy-main
runs-on: ubuntu-latest
needs: CI
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: 리모트 쉘 접속
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_DEPLOY_HOST }}
username: ${{ secrets.EC2_DEPLOY_USER }}
key: ${{ secrets.EC2_DEPLOY_SSH_KEY }}
script: |
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
echo "해당 리포지토리로 이동"
cd $HOME/24-not-enough
echo "리포지토리 pull"
git pull origin main
echo "앱 빌드"
npm install
npm run build
echo "앱 배포 (reload)"
pm2 reload 24-not-enough