Skip to content

Commit

Permalink
[Feat]: ci-cd 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
bayy1216 committed May 31, 2024
1 parent 7d7602a commit 701d653
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ jobs:
needs: ci # ci job이 성공적으로 끝나야 cd job이 실행됩니다.

# appleboy/ssh-action@master 액션을 사용하여 지정한 서버에 ssh로 접속하고, script를 실행합니다.
# script의 내용은 도커의 기존 프로세스들을 제거하고, docker repo로부터 방금 위에서 push한 내용을 pull 받아 실행하는 것입니다.
# script의 내용은 도커의 기존 프로세스들을 제거하고, docker repo로부터 방금 위에서 push한 내용을 pull 받아 실행하는 것입니다.
# 실행 시, docker-compose를 사용합니다.
steps:
- name: ✔️ send docker-compose.yml to EC2 server
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.HOST }}
key: ${{ secrets.KEY }}
port: 22
source: "./docker-compose.dev.yml"
target: "/home/ec2-user"

- name: Deploy to server
uses: appleboy/ssh-action@master
id: deploy
Expand All @@ -53,4 +63,6 @@ jobs:
docker rmi $(docker images -q) # 기존에 존재하는 도커 이미지들을 제거합니다.
docker image prune -f # 사용하지 않는 도커 이미지들을 제거합니다.
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }}
docker run -d -p 80:8080 ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }}
# docker run -d -p 80:8080 ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }}
docker-compose -f /home/ec2-user/docker-compose.dev.yml up -d
22 changes: 19 additions & 3 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '3'
# 실행명령어
# docker-compose -f ./docker-compose.dev.yml up
# 실행명령어
# docker-compose -f ./docker-compose.dev.yml up
services:
zzansuni-mysql:
image: mysql
Expand All @@ -11,4 +11,20 @@ services:
- "3306:3306"
environment:
MYSQL_DATABASE: zzansuni
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
zzanuni-spring:
image: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }}
restart: always
ports:
- "80:8080"
depends_on:
- zzansuni-mysql
environment:
SPRING_PROFILES_ACTIVE: dev
JWT_SECRET: 4099a46b-39db-4860-a61b-2ae76ea24c43
KAKAO_CLIENT_ID: ${{ secrets.KAKAO_CLIENT_ID }}
KAKAO_CLIENT_SECRET: ${{ secrets.KAKAO_CLIENT_SECRET }}
KAKAO_REDIRECT_URI: ${{ secrets.KAKAO_REDIRECT_URI }}
NAVER_CLIENT_ID: ${{ secrets.NAVER_CLIENT_ID }}
NAVER_CLIENT_SECRET: ${{ secrets.NAVER_CLIENT_SECRET }}

0 comments on commit 701d653

Please sign in to comment.