Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Deployment
name: Backend Continuous Deployment

on:
push:
Expand All @@ -9,27 +9,25 @@ jobs:
runs-on: ubuntu-24.04

steps:
# 1. Compare branch 코드 내려 받기
- name: Checkout PR
# 1. 브랜치 checkout
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

# 2. 자바 환경 설정
# 2. JDK 설정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
java-version: "17"
distribution: "temurin"

# 3. Docker 이미지 build 및 push
# 3. Docker 이미지 build 및 push
- name: docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/gotcha:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/gotcha:latest

# 4. ec2 pull
# 4. backend 서비스 재시작
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
Expand All @@ -39,9 +37,17 @@ jobs:
key: ${{ secrets.SERVER_KEY }}
script: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker system prune -a -f
docker-compose down
docker rmi ${{ secrets.DOCKER_USERNAME }}/gotcha:latest

echo "==== BACKEND 컨테이너 중지 ===="
docker-compose stop app || true

echo "==== 오래된 BACKEND 이미지 삭제 ===="
docker rmi ${{ secrets.DOCKER_USERNAME }}/gotcha:latest || true

echo "==== 최신 BACKEND 이미지 pull ===="
docker pull ${{ secrets.DOCKER_USERNAME }}/gotcha:latest
docker-compose up -d

echo "==== BACKEND만 재시작 ===="
docker-compose up -d app

echo "==== 백엔드 배포 완료! ===="
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ResponseCookie createCookie(String key, String value, boolean autoSignIn)
.path("/")
.httpOnly(true)
.secure(secure)
.sameSite(secure ? "None" : "Lax");
.sameSite(secure ? "Strict" : "Lax");

if(autoSignIn)
cookie.maxAge(COOKIE_REFRESH_EXPIRATION);
Expand All @@ -35,7 +35,7 @@ public void deleteCookie(String cookieName, HttpServletResponse response) {
.httpOnly(true)
.maxAge(0)
.secure(secure)
.sameSite(secure ? "None" : "Lax")
.sameSite(secure ? "Strict" : "Lax")
.build();

response.addHeader("Set-Cookie", cookie.toString());
Expand Down
Loading