Skip to content

Commit 5b9e049

Browse files
wonieswonieseyeon22222
authored
✨ [Feature] 모니터링스레드 - 42api event받아오기 / 기간지난 이벤트 deactivate / slack봇 알람 기능 구현 #1152 (#1155)
Co-authored-by: wonie <[email protected]> Co-authored-by: seyeon22222 <[email protected]>
1 parent f58ae8f commit 5b9e049

28 files changed

Lines changed: 482 additions & 180 deletions

File tree

.github/workflows/checkstyle-validation.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: 👮Checkstyle validation
22

33
on:
4+
push:
5+
branches: [ 1151-feature-42api-모니터링스레드에작업 ]
46
pull_request:
5-
branches: [ main, dev , recruit-dev]
7+
branches: [ main, dev ]
68

79
jobs:
810
checkstyle:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dev": {
3+
"name": "value"
4+
}
5+
}

.github/workflows/test-code-validation.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: 💻 Test code validation
22

33
on:
4+
push:
5+
branches: [ 1151-feature-42api-모니터링스레드에작업 ]
46
pull_request:
5-
branches: [main, dev]
7+
branches: [ main, dev ]
68

79
jobs:
810
test:

.github/workflows/test-deploy.yml

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7-
81
name: test-deploy
92

103
on:
114
push:
12-
branches: [ dev ]
5+
branches: [ dev, 1151-feature-42api-모니터링스레드에작업 ]
136
workflow_dispatch:
147

15-
env:
16-
DOCKER_USER: ${{ secrets.DOCKER_USER }}
17-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
18-
IMAGE_NAME: wken5577/test-migrate-server
19-
208
permissions:
219
contents: read
2210

@@ -41,52 +29,8 @@ jobs:
4129
echo "${{ secrets.MIGRATE_APPLICATION_YML }}" | base64 -d > application.yml
4230
shell: bash
4331

44-
- name: Login to Docker Hub
45-
uses: docker/login-action@v1
46-
with:
47-
username: ${{ env.DOCKER_USER }}
48-
password: ${{ env.DOCKER_PASSWORD }}
49-
5032
- name: Test with Gradle
5133
run: ./gradlew clean test
5234

5335
- name: Build with Gradle
5436
run: ./gradlew clean build -x test
55-
56-
- name: build new docker image as latest tag
57-
run: |
58-
docker build -t ${{ env.IMAGE_NAME }}:latest .
59-
docker push ${{ env.IMAGE_NAME }}:latest
60-
61-
- name: Create the configuration file
62-
run: |
63-
cat << EOF > config.json
64-
{
65-
"AutoScalingGroupName": "gg-dev",
66-
"DesiredConfiguration": {
67-
"LaunchTemplate": {
68-
"LaunchTemplateId": "${{ secrets.DEV_LAUNCH_TEMPLATE_ID }}",
69-
"Version": "\$Latest"
70-
}
71-
},
72-
"Preferences": {
73-
"MinHealthyPercentage": 100,
74-
"MaxHealthyPercentage": 110,
75-
"InstanceWarmup": 300,
76-
"ScaleInProtectedInstances": "Ignore",
77-
"StandbyInstances": "Ignore"
78-
}
79-
}
80-
EOF
81-
cat config.json
82-
83-
- name: Configure AWS CLI
84-
uses: aws-actions/configure-aws-credentials@v2
85-
with:
86-
aws-access-key-id: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }}
87-
aws-secret-access-key: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }}
88-
aws-region: ap-northeast-2
89-
90-
- name: Trigger Instance Refresh
91-
run: |
92-
aws autoscaling start-instance-refresh --cli-input-json file://config.json

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ plugins {
88
id 'checkstyle'
99
}
1010

11+
java {
12+
sourceCompatibility = JavaVersion.VERSION_11
13+
targetCompatibility = JavaVersion.VERSION_11
14+
}
15+
1116
editorconfig {
1217
excludes = ['build']
1318
}

gg-admin-repo/src/test/java/gg/admin/repo/TestSpringBootApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
import org.springframework.boot.autoconfigure.SpringBootApplication;
44

55
@SpringBootApplication(scanBasePackages = {"gg.recruit.api", "gg.utils", "gg.data", "gg.repo",
6-
"gg.admin.repo", "gg.auth", "gg.pingpong.api"})
6+
"gg.admin.repo", "gg.auth", "gg.pingpong.api", "gg.calendar.api"})
77
public class TestSpringBootApplication {
88
}

gg-auth/src/main/java/gg/auth/FortyTwoAuthUtil.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@
2323
import org.springframework.util.LinkedMultiValueMap;
2424
import org.springframework.util.MultiValueMap;
2525

26+
import gg.auth.config.ScheduleConfig;
2627
import gg.utils.exception.ErrorCode;
2728
import gg.utils.exception.custom.NotExistException;
2829
import gg.utils.exception.user.TokenNotValidException;
2930
import gg.utils.external.ApiUtil;
3031
import lombok.RequiredArgsConstructor;
32+
import lombok.extern.slf4j.Slf4j;
3133

34+
@Slf4j
3235
@Component
3336
@RequiredArgsConstructor
3437
public class FortyTwoAuthUtil {
3538
private final ApiUtil apiUtil;
3639
private final OAuth2AuthorizedClientService authorizedClientService;
40+
private final ScheduleConfig scheduleConfig;
3741

3842
public String getAccessToken() {
3943
Authentication authentication = getAuthenticationFromContext();
@@ -62,6 +66,32 @@ public String refreshAccessToken() {
6266
return newClient.getAccessToken().getTokenValue();
6367
}
6468

69+
/* 42event client credential token */
70+
public String getClientCredentialToken() {
71+
HttpHeaders headers = new HttpHeaders();
72+
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
73+
74+
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
75+
params.add("grant_type", "client_credentials");
76+
params.add("client_id", scheduleConfig.getClientId());
77+
params.add("client_secret", scheduleConfig.getClientSecret());
78+
79+
try {
80+
Map<String, Object> response = apiUtil.apiCall(
81+
scheduleConfig.getTokenUri(),
82+
Map.class,
83+
headers,
84+
params,
85+
HttpMethod.POST
86+
);
87+
log.info("Raw Api Response : {}", response);
88+
// System.out.println("Response : " + response);
89+
return (String)response.get("access_token");
90+
} catch (Exception e) {
91+
throw new TokenNotValidException();
92+
}
93+
}
94+
6595
private Authentication getAuthenticationFromContext() {
6696
SecurityContext context = SecurityContextHolder.getContext();
6797
return context.getAuthentication();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package gg.auth.config;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
import lombok.Getter;
7+
8+
@Configuration
9+
@Getter
10+
public class ScheduleConfig {
11+
@Value("${spring.security.oauth2.client.registration.42.client-id}")
12+
private String clientId;
13+
@Value("${spring.security.oauth2.client.registration.42.client-secret}")
14+
private String clientSecret;
15+
@Value("${spring.security.oauth2.client.provider.42.token-uri}")
16+
private String tokenUri;
17+
}

gg-calendar-api/src/main/java/gg/api42/ApiClient.java

Lines changed: 0 additions & 78 deletions
This file was deleted.

gg-calendar-api/src/main/java/gg/calendar/api/admin/schedule/publicschedule/controller/PublicScheduleAdminController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,5 @@ public ResponseEntity<Void> publicScheduleDelete(@PathVariable Long id) {
6161
public ResponseEntity<PublicScheduleAdminResDto> publicScheduleDetail(@PathVariable Long id) {
6262
PublicScheduleAdminResDto publicScheduleAdminResDto = publicScheduleAdminService.detailPublicSchedule(id);
6363
return ResponseEntity.ok(publicScheduleAdminResDto);
64-
6564
}
6665
}

0 commit comments

Comments
 (0)