Skip to content

Commit

Permalink
[CHORE] 운영 서버 github actions 테스트 (#151)
Browse files Browse the repository at this point in the history
* [CHORE] 운영 서버 workflow 작성 및 개발 서버 workflow 파일 이름 변경 (#145)

* rename: docker-deploy.yml -> dev-deploy.yml

* chore: 운영 환경 workflow 파일 작성

* [FEAT] 로그아웃 HTTP method 변경 (#150)

* feat: 로그아웃 비즈니스 예외 구현

* refactor: 로그아웃 method 변경

GET에서 POST로 변경

* config: 프론트 URL 변경

---------

Co-authored-by: 강명덕 <[email protected]>
  • Loading branch information
injae-348 and Profile-exe authored Sep 12, 2024
1 parent aec89d5 commit 88d4410
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
File renamed without changes.
46 changes: 46 additions & 0 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Prod CI/CD

on:
workflow_dispatch:
push:
branches: [ "production" ]

permissions:
contents: read

jobs:

build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'

- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test
- name: Build the Docker image
run: |
docker login -u ${{ secrets.PROD_DOCKER_USERNAME }} -p ${{ secrets.PROD_DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.PROD_DOCKER_REPO }} .
docker push ${{ secrets.PROD_DOCKER_REPO }}
- name: Deploy to server
uses: appleboy/ssh-action@master
id: deploy
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USERNAME }}
key: ${{ secrets.PROD_KEY }}
envs: GITHUB_SHA
script: |
cd ./buddies
bash deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import econo.buddybridge.auth.OAuthProvider;
import econo.buddybridge.auth.dto.kakao.KakaoLoginParams;
import econo.buddybridge.auth.exception.AlreadyLogoutException;
import econo.buddybridge.auth.service.OAuthLoginService;
import econo.buddybridge.common.annotation.AllowAnonymous;
import econo.buddybridge.member.dto.MemberResDto;
Expand Down Expand Up @@ -39,15 +40,15 @@ public class AuthController {

@Operation(summary = "로그아웃", description = "세션을 제거합니다.")
@AllowAnonymous
@GetMapping("/logout")
@PostMapping("/logout")
public ApiResponse<CustomBody<String>> logout(HttpServletRequest request) {
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
oAuthLoginService.logout(OAuthProvider.KAKAO);
return ApiResponseGenerator.success("로그아웃 성공", HttpStatus.OK);
}
return ApiResponseGenerator.success("이미 로그아웃 상태입니다.", HttpStatus.OK);
throw AlreadyLogoutException.EXCEPTION;
}

@Operation(summary = "카카오 소셜 로그인 (코드로 로그인)", description = "Redirect URL이 백엔드 주소로 설정될 때 사용합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package econo.buddybridge.auth.exception;

import econo.buddybridge.common.exception.BusinessException;

public class AlreadyLogoutException extends BusinessException {

public static BusinessException EXCEPTION = new AlreadyLogoutException();

public AlreadyLogoutException() {
super(AuthErrorCode.ALREADY_LOGOUT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public enum AuthErrorCode implements ErrorCode {
SESSION_ALREADY_EXISTS("A001", HttpStatus.BAD_REQUEST, "이미 세션이 존재합니다. 삭제 응답 후 다시 시도해주세요."),
FEIGN_REDIRECT("A002", HttpStatus.OK, "Feign Client Logout Redirect"),
FEIGN_KAKAO_EXCEPTION("A003", HttpStatus.BAD_REQUEST, "카카오 API 호출 오류가 발생했습니다."),
ALREADY_LOGOUT("A004", HttpStatus.BAD_REQUEST, "이미 로그아웃 상태입니다."),
;

private final String code;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/econo/buddybridge/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public void addCorsMappings(CorsRegistry registry) { // CORS 설정
"http://localhost:3000", "https://localhost:3000",
"http://localhost:8080", "https://localhost:8080",
"http://localhost:8081", "https://localhost:8081",
"https://buddybridge-git-master-simminbos-projects.vercel.app/",
"https://buddybridge-simminbos-projects.vercel.app/"
"https://buddy-bridge.vercel.app/"
)
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
Expand Down

0 comments on commit 88d4410

Please sign in to comment.