Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#92] CICD #93

Merged
merged 4 commits into from
Jul 9, 2024
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
126 changes: 63 additions & 63 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
#name: Travel Compass Dev CI/CD
#
#on:
# pull_request:
# types:
# - closed
# workflow_dispatch:
#
#jobs:
# build:
# runs-on: ubuntu-latest
# if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop'
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Set up JDK 17
# uses: actions/[email protected]
# with:
# java-version: '17'
# distribution: 'adopt'
#
# - name: Grant execute permission for gradlew
# run: chmod +x gradlew
# shell: bash
#
# - name: Build with Gradle
# run: ./gradlew clean build -x test
# shell: bash
#
# - name: Get current time
# uses: josStorer/get-current-time@v2
# id: current-time
# with:
# format: 'YYYY-MM-DDTHH:mm:ss'
# utcOffset: '+09:00'
#
# - name: Show current time
# run: echo "${{ steps.current-time.outputs.formattedTime }}"
# shell: bash
#
# - name: Generate deployment package
# run: |
# mkdir -p deploy
# cp build/libs/*.jar deploy/application.jar
# cp Procfile deploy/Procfile
# cp -r .ebextensions_dev deploy/.ebextensions
# cp -r .platform deploy/.platform
# cd deploy && zip -r deploy.zip .
#
# - name: Deploy to Elastic Beanstalk
# uses: einaregilsson/beanstalk-deploy@v20
# with:
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# application_name: 'travel-compass-dev'
# environment_name: 'Travel-compass-dev-env'
# version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
# region: 'ap-northeast-2'
# deployment_package: 'deploy/deploy.zip'
# wait_for_deployment: false
#
name: Travel Compass Dev CI/CD

on:
pull_request:
types:
- closed
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'adopt'

- name: Grant execute permission for gradlew
run: chmod +x gradlew
shell: bash

- name: Build with Gradle
run: ./gradlew clean build -x test
shell: bash

- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: 'YYYY-MM-DDTHH:mm:ss'
utcOffset: '+09:00'

- name: Show current time
run: echo "${{ steps.current-time.outputs.formattedTime }}"
shell: bash

- name: Generate deployment package
run: |
mkdir -p deploy
cp build/libs/*.jar deploy/application.jar
cp Procfile deploy/Procfile
cp -r .ebextensions_dev deploy/.ebextensions
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .

- name: Deploy to Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v20
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: 'travel-compass-dev'
environment_name: 'Travel-compass-dev-env'
version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
region: 'ap-northeast-2'
deployment_package: 'deploy/deploy.zip'
wait_for_deployment: false

1 change: 1 addition & 0 deletions .platform/nginx/confid/client_max_body_size.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client_max_body_size 200M;
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public OpenAPI api() {
.components(components);
}

// 사용자 auth -> swagger 사용 가능
@Bean
public GroupedOpenApi allGroup(){
return GroupedOpenApi.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ protected SecurityFilterChain securityFilterChain(
"/token/**", // 로컬에게 토큰 반환
"/oauth/**", // 프론트에게 토큰 반환

"/swagger-ui/**", // Swagger UI
"/v3/api-docs/**", // Swagger API docs
"/swagger-resources/**", // Swagger resources

"/locations/regions/**", // 지역별 장소 리스트 조회
"/locations/**", // 장소 상세 조회

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ public class OAuth2SuccessHandler extends SimpleUrlAuthenticationSuccessHandler
private final JwtTokenUtils tokenUtils;
private final UserDetailsManager userDetailsManager;
private final RefreshTokenRepository refreshTokenRepository;
// private final RefreshTokenRedisRepository;

public OAuth2SuccessHandler(
JwtTokenUtils tokenUtils,
UserDetailsManager userDetailsManager,
RefreshTokenRepository refreshTokenRepository
// RefreshTokenRedisRepository
) {
this.tokenUtils = tokenUtils;
this.userDetailsManager = userDetailsManager;
this.refreshTokenRepository = refreshTokenRepository;
// this.refreshTokenRedisRepository = refreshTokenRedisRepository;
}

@Override
Expand Down Expand Up @@ -102,9 +99,13 @@ public void onAuthenticationSuccess(

// 목적지 URL 설정 - 토큰 던짐
String targetUrl = String.format(
"http://travel-compass.netlify.app/oauth/callback?access-token=%s&refresh-token=%s",
jwt.getAccessToken(), jwt.getRefreshToken()
// "http://localhost:8080/token/token?access-token=%s&refresh-token=%s", jwt.getAccessToken(), jwt.getRefreshToken()
// 로컬
"http://localhost:8080/token/token?access-token=%s&refresh-token=%s", jwt.getAccessToken(), jwt.getRefreshToken()
// 프론트 도메인
// "http://travel-compass.netlify.app/oauth/callback?access-token=%s&refresh-token=%s", jwt.getAccessToken(), jwt.getRefreshToken()
// 백 도메인
// "http://umc.persi0815:8080/token/token?access-token=%s&refresh-token=%s", jwt.getAccessToken(), jwt.getRefreshToken()

);
// 실제 Redirect 응답 생성
getRedirectStrategy().sendRedirect(request, response, targetUrl);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
public class UserService {
private final UserRepository userRepository;
private final RefreshTokenRepository refreshTokenRepository;
// private final RefreshTokenRedisRepository refreshTokenRedisRepository;

private final PasswordEncoder passwordEncoder;
private final JpaUserDetailsManager manager;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ spring:
# 서비스 제공자측에 저희가 어떤 서비스인지 인증하기 위한 값
client-id: 3tVKSO15tNGbkeZJf8eE #서비스 제공자측에 저희가 어떤 서비스인지 인증하기 위한 값
client-secret: zHvANLwWHH
redirect-uri: http://umc.persi0815.site:8080/login/oauth2/code/naver
# redirect-uri: http://localhost:8080/login/oauth2/code/naver
# redirect-uri: http://umc.persi0815.site:8080/login/oauth2/code/naver
redirect-uri: http://localhost:8080/login/oauth2/code/naver
authorization-grant-type: authorization_code # 어떤 방식으로 access token을 받을지 정의
client-authentication-method: client_secret_post # Client Id, Client Secret를 요청의 어디에 포함할지 정의. Body
client-name: Naver
Expand Down
Loading