-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (120 loc) · 5.39 KB
/
deploy.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: ssh for main deploy # workflow의 이름을 지정해준다.
on: # 작동 트리거로 설정할 부분을 작성하는 곳이다.
push: # 이 스크립트는 개발서버용 이므로 dev 브렌치에 push될 때 작동하도록 해두었다.
branches: [main]
# jobs에선 action의 단계(step)를 설정할 수 있다.
# 여러 개의 job을 사용할 수 있고, job끼리 서로 정보를 교환할 수도 있다.
jobs:
deploy:
name: Deploy # job의 이름을 지정해 준다.
runs-on: ubuntu-latest # job을 실행할 환경을 정해준다.
steps:
# Github Actions는 해당 프로젝트를 리눅스 환경에 checkout하고 나서 실행한다.
# 꼭 필요한 과정!
# 누가 만들어 놓은 Action을 사용할 때에는 uses 키워드를 사용한다.
- uses: actions/[email protected]
- uses: dorny/[email protected]
id: changes
with:
filters: |
back:
- 'back/**'
front:
- 'front/**'
devops:
- 'devops/**'
database:
- 'database/**'
- name: Default Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SSH_HOST }}
username: ${{ secrets.REMOTE_SSH_USERNAME }}
password: ${{ secrets.REMOTE_SSH_PASSWORD}}
port: ${{ secrets.REMOTE_SSH_PORT }}
timeout: 40s
script: |
echo "##Default CICD##"
echo "############# GIT PULL #############"
cd ~/server
pass=$(git pull origin main)
echo $pass
if [ -n "$pass" ]; then
echo "############# Processing for Default Deploy #############"
else
echo "############## Git Pull: Error ##############"
exit 1;
fi
echo "############### Finish Default ##############"
# step의 이름을 지정해준다.
- name: deploy backend with connecting My PC via SSH
if: steps.changes.outputs.back == 'true'
# 위에 말했던 appleboy의 Action을 사용
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SSH_HOST }}
username: ${{ secrets.REMOTE_SSH_USERNAME }}
password: ${{ secrets.REMOTE_SSH_PASSWORD}}
port: ${{ secrets.REMOTE_SSH_PORT }}
timeout: 40s
script: |
echo "# BACKEND DEPLOYING START!!!"
cd ~/server/back
echo "############# Processing for Backend Deploy #############"
build='Successfully built'
docker compose -f docker-compose.back.yml up -d --build
echo "############### Finish Backend ##############"
###########################################################################
- name: deploy frontend with connecting My PC via SSH
if: steps.changes.outputs.frontend == 'true'
# 위에 말했던 appleboy의 Action을 사용
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SSH_HOST }}
username: ${{ secrets.REMOTE_SSH_USERNAME }}
password: ${{ secrets.REMOTE_SSH_PASSWORD}}
port: ${{ secrets.REMOTE_SSH_PORT }}
timeout: 40s
script: |
echo "# FRONTEND DEPLOYING START!!!"
cd ~/server/front
echo "############# Processing for Frontend Deploy #############"
build='Successfully built'
docker compose -f docker-compose.front.yml up -d --build
echo "############### Finish Frontend ##############"
###########################################################################
- name: deploy database with connecting My PC via SSH
if: steps.changes.outputs.database == 'true'
# 위에 말했던 appleboy의 Action을 사용
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SSH_HOST }}
username: ${{ secrets.REMOTE_SSH_USERNAME }}
password: ${{ secrets.REMOTE_SSH_PASSWORD}}
port: ${{ secrets.REMOTE_SSH_PORT }}
timeout: 40s
script: |
echo "# DATABASE DEPLOYING START!!!"
cd ~/server/database
echo "############# Processing for Database Deploy #############"
build='Successfully built'
docker compose -f docker-compose.database.yml up -d --build
echo "############### Finish Database ##############"
###########################################################################
- name: deploy devops with connecting My PC via SSH
if: steps.changes.outputs.devops == 'true'
# 위에 말했던 appleboy의 Action을 사용
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_SSH_HOST }}
username: ${{ secrets.REMOTE_SSH_USERNAME }}
password: ${{ secrets.REMOTE_SSH_PASSWORD}}
port: ${{ secrets.REMOTE_SSH_PORT }}
timeout: 40s
script: |
echo "# DEVOPS DEPLOYING START!!!"
cd ~/server/devops
echo "############# Processing for DevOps Deploy #############"
build='Successfully built'
docker compose -f docker-compose.devops.yml up -d --build
echo "############### Finish DevOps ##############"