Skip to content

Commit daa0b38

Browse files
author
jin.geonwoo
committed
[hotfix] NCP-CI-CD.yml 파일 추가
1 parent 3798051 commit daa0b38

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

.github/workflows/NCP-CI-CI.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: NCP-CI-CD
2+
on:
3+
push:
4+
branches: [ "develop" ]
5+
6+
jobs:
7+
ci:
8+
runs-on: ubuntu-latest
9+
env:
10+
working-directory: .
11+
12+
steps:
13+
- name: 체크아웃
14+
uses: actions/checkout@v3
15+
16+
- name: JDK 설정
17+
uses: actions/setup-java@v3
18+
with:
19+
distribution: 'corretto'
20+
java-version: '17'
21+
22+
- name: application.yml 생성
23+
run: |
24+
mkdir -p ./src/main/resources && cd $_
25+
touch ./application.yml
26+
echo "${{ secrets.YML }}" > ./application.yml
27+
cat ./application.yml
28+
working-directory: ${{ env.working-directory }}
29+
30+
- name: 빌드
31+
run: |
32+
chmod +x gradlew
33+
./gradlew build -x test
34+
working-directory: ${{ env.working-directory }}
35+
shell: bash
36+
37+
- name: docker 로그인
38+
uses: docker/setup-buildx-action@v2.9.1
39+
40+
- name: login docker hub
41+
uses: docker/login-action@v2.2.0
42+
with:
43+
username: ${{ secrets.DOCKER_LOGIN_USERNAME }}
44+
password: ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }}
45+
46+
- name: docker image 빌드 및 푸시
47+
run: |
48+
docker build --platform linux/amd64 -t recordy/recordy .
49+
docker push recordy/recordy
50+
working-directory: ${{ env.working-directory }}
51+
52+
cd:
53+
needs: ci
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: 체크아웃
58+
uses: actions/checkout@v3
59+
60+
- name: ec2 서버에 deploy.sh
61+
uses: appleboy/scp-action@master
62+
with:
63+
host: ${{ secrets.NCP_SERVER_IP }}
64+
username: ${{ secrets.NCP_SERVER_USER }}
65+
password: ${{ secrets.NCP_SERVER_PASSWORD }}
66+
source: ./scripts/deploy.sh
67+
target: /home/ubuntu/
68+
69+
- name: ec2 서버에 docker-compose.yml 전송
70+
uses: appleboy/scp-action@master
71+
with:
72+
host: ${{ secrets.NCP_SERVER_IP }}
73+
username: ${{ secrets.NCP_SERVER_USER }}
74+
password: ${{ secrets.NCP_SERVER_PASSWORD }}
75+
source: ./docker-compose.yml
76+
target: /home/ubuntu/
77+
78+
- name: docker image 풀 및 deploy.sh 통해 블루-그린 배포 진행
79+
uses: appleboy/ssh-action@master
80+
with:
81+
host: ${{ secrets.NCP_SERVER_IP }}
82+
username: ${{ secrets.NCP_SERVER_USER }}
83+
password: ${{ secrets.NCP_SERVER_PASSWORD }}
84+
script: |
85+
sudo docker login -u ${{ secrets.DOCKER_LOGIN_USERNAME }} -p ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }}
86+
sudo chmod 777 /home/ubuntu/scripts/deploy.sh
87+
/home/ubuntu/scripts/deploy.sh
88+
docker image prune -f

0 commit comments

Comments
 (0)