Skip to content

Commit 9ebaed7

Browse files
authored
Merge pull request #19 from team-gogo/develop
v2025.4.1
2 parents 9706189 + 1d77dd9 commit 9ebaed7

26 files changed

+457
-62
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: GOGO Betting prod CD Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
workflow_dispatch:
8+
9+
jobs:
10+
CI:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
cache: gradle
23+
24+
- name: Setup Gradle
25+
uses: gradle/gradle-build-action@v2
26+
27+
- name: Setup Gradle's permission
28+
run: chmod +x gradlew
29+
30+
- name: Build with Gradle
31+
run: ./gradlew clean build
32+
33+
deploy:
34+
needs: CI
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v3
39+
40+
- name: Install sshpass and OpenSSH
41+
run: |
42+
sudo apt-get update && sudo apt-get install -y sshpass openssh-client
43+
44+
- name: Create SSH key for Bastion and Target
45+
run: |
46+
echo "${{ secrets.PROD_BASTION_SSH_KEY }}" > $HOME/bastion_key.pem
47+
chmod 600 $HOME/bastion_key.pem
48+
49+
- name: SSH Command to Deploy using Bastion and Target Instance
50+
run: |
51+
ssh -i "$HOME/bastion_key.pem" -o StrictHostKeyChecking=no ubuntu@${{ secrets.PROD_BASTION_HOST }} << 'EOF'
52+
ssh -i gogo-prod-ms.pem -o StrictHostKeyChecking=no ubuntu@${{ secrets.PROD_TARGET_HOST }} << 'EOF2'
53+
mkdir -p /home/ubuntu/gogo-betting
54+
cd /home/ubuntu/gogo-betting
55+
56+
if [ ! -d ".git" ]; then
57+
git clone -b master https://github.com/team-gogo/gogo-betting.git .
58+
else
59+
git pull origin master
60+
fi
61+
62+
./gradlew clean build
63+
64+
docker build -f DockerFileProd -t gogo-betting-prod .
65+
66+
docker stop gogo-betting-prod || true
67+
docker rm gogo-betting-prod || true
68+
69+
docker run -d -p 8083:8083 --add-host host.docker.internal:host-gateway --name gogo-betting-prod gogo-betting-prod
70+
71+
- name: SSH Success Notification
72+
if: success()
73+
uses: sarisia/actions-status-discord@v1
74+
with:
75+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
76+
color: 0x4CAF50
77+
title: "배포 성공"
78+
message: "GOGO Betting prod deployment completed successfully."
79+
80+
- name: SSH Failure Notification
81+
if: failure()
82+
uses: sarisia/actions-status-discord@v1
83+
with:
84+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
85+
color: 0xFF4C4C
86+
title: "배포 실패"
87+
message: "GOGO Betting prod deployment failed. Check the logs for details."
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: GOGO Betting prod CI Workflow
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'master'
7+
push:
8+
branches:
9+
- 'master'
10+
workflow_dispatch:
11+
12+
jobs:
13+
CI:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v3
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
cache: gradle
26+
27+
- name: Setup Gradle
28+
uses: gradle/gradle-build-action@v2
29+
30+
- name: Setup Gradle's permission
31+
run: chmod +x gradlew
32+
33+
- name: Build with Gradle
34+
run: ./gradlew clean build
35+
36+
- name: CI Success Notification
37+
uses: sarisia/actions-status-discord@v1
38+
if: success()
39+
with:
40+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
41+
color: 0x4CAF50
42+
43+
- name: CI Failure Notification
44+
uses: sarisia/actions-status-discord@v1
45+
if: failure()
46+
with:
47+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
48+
color: 0xFF4C4C
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: GOGO Betting stage CD Workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- 'develop'
7+
workflow_dispatch:
8+
9+
jobs:
10+
CI:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
cache: gradle
23+
24+
- name: Setup Gradle
25+
uses: gradle/gradle-build-action@v2
26+
27+
- name: Setup Gradle's permission
28+
run: chmod +x gradlew
29+
30+
- name: Build with Gradle
31+
run: ./gradlew clean build
32+
33+
deploy:
34+
needs: CI
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v3
39+
40+
- name: Install sshpass and OpenSSH
41+
run: |
42+
sudo apt-get update && sudo apt-get install -y sshpass openssh-client
43+
44+
- name: Create SSH key for Bastion and Target
45+
run: |
46+
echo "${{ secrets.STAGE_BASTION_SSH_KEY }}" > $HOME/bastion_key.pem
47+
chmod 600 $HOME/bastion_key.pem
48+
49+
- name: SSH Command to Deploy using Bastion and Target Instance
50+
run: |
51+
ssh -i "$HOME/bastion_key.pem" -o StrictHostKeyChecking=no ubuntu@${{ secrets.STAGE_BASTION_HOST }} << 'EOF'
52+
ssh -i gogo-stage.pem -o StrictHostKeyChecking=no ubuntu@${{ secrets.STAGE_TARGET_HOST }} << 'EOF2'
53+
mkdir -p /home/ubuntu/gogo-betting
54+
cd /home/ubuntu/gogo-betting
55+
56+
if [ ! -d ".git" ]; then
57+
git clone -b develop https://github.com/team-gogo/gogo-betting.git .
58+
else
59+
git pull origin develop
60+
fi
61+
62+
./gradlew clean build
63+
64+
docker build -f DockerFileStage -t gogo-betting-stage .
65+
66+
docker stop gogo-betting-stage || true
67+
docker rm gogo-betting-stage || true
68+
69+
docker run -d -p 8083:8083 --add-host host.docker.internal:host-gateway --name gogo-betting-stage gogo-betting-stage
70+
71+
- name: SSH Success Notification
72+
if: success()
73+
uses: sarisia/actions-status-discord@v1
74+
with:
75+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
76+
color: 0x4CAF50
77+
title: "배포 성공"
78+
message: "GOGO User stage deployment completed successfully."
79+
80+
- name: SSH Failure Notification
81+
if: failure()
82+
uses: sarisia/actions-status-discord@v1
83+
with:
84+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
85+
color: 0xFF4C4C
86+
title: "배포 실패"
87+
message: "GOGO User stage deployment failed. Check the logs for details."
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: GOGO Betting stage CI Workflow
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- 'develop'
7+
push:
8+
branches:
9+
- 'develop'
10+
workflow_dispatch:
11+
12+
jobs:
13+
CI:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v3
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
cache: gradle
26+
27+
- name: Setup Gradle
28+
uses: gradle/gradle-build-action@v2
29+
30+
- name: Setup Gradle's permission
31+
run: chmod +x gradlew
32+
33+
- name: Build with Gradle
34+
run: ./gradlew clean build
35+
36+
- name: CI Success Notification
37+
uses: sarisia/actions-status-discord@v1
38+
if: success()
39+
with:
40+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
41+
color: 0x4CAF50
42+
43+
- name: CI Failure Notification
44+
uses: sarisia/actions-status-discord@v1
45+
if: failure()
46+
with:
47+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
48+
color: 0xFF4C4C

DockerFileProd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM openjdk:17-jdk
2+
3+
EXPOSE 8083
4+
5+
WORKDIR /home/ubuntu/gogo-betting
6+
7+
COPY build/libs/gogo-betting-0.0.1-SNAPSHOT.jar prod-betting.jar
8+
9+
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
10+
11+
ENTRYPOINT ["java", "-jar", "prod-betting.jar", "--spring.profiles.active=prod"]

DockerFileStage

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM openjdk:17-jdk
2+
3+
EXPOSE 8083
4+
5+
WORKDIR /home/ubuntu/gogo-betting
6+
7+
COPY build/libs/gogo-betting-0.0.1-SNAPSHOT.jar stage-betting.jar
8+
9+
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
10+
11+
ENTRYPOINT ["java", "-jar", "stage-betting.jar", "--spring.profiles.active=stage"]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# GOGO Betting Service
2+
GOGO Betting 서비스입니다.

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ extra["springCloudVersion"] = "2024.0.0"
3131
dependencies {
3232
runtimeOnly("io.micrometer:micrometer-registry-prometheus")
3333
implementation("org.springframework.boot:spring-boot-starter-actuator")
34-
implementation("org.springframework.cloud:spring-cloud-starter-bus-kafka")
3534
implementation("org.springframework.cloud:spring-cloud-starter-config")
3635
implementation("com.querydsl:querydsl-jpa:5.0.0:jakarta")
3736
kapt("com.querydsl:querydsl-apt:5.0.0:jakarta")

src/main/kotlin/gogo/gogobetting/domain/batch/root/application/BatchReader.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BatchReader(
1515
fun readBettingOdds(matchId: Long, winTeamId: Long): Double =
1616
bettingRepository.calcOdds(matchId, winTeamId).odds
1717

18-
fun readByMatchId(matchId: Long) = batchRepository.findByMatchIdAndIsCancelledFalse(matchId)
18+
fun readByMatchIdForWrite(matchId: Long) = batchRepository.findByMatchIdAndIsCancelledFalse(matchId)
1919
?: throw BettingException("Not Found Batch, Match Id: $matchId", HttpStatus.NOT_FOUND.value())
2020

2121
}

src/main/kotlin/gogo/gogobetting/domain/batch/root/application/BatchServiceImpl.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ class BatchServiceImpl(
2323
) : BatchService {
2424

2525
override fun batch(matchId: Long, dto: BatchDto) {
26-
// 동시성 처리 필요
2726
val studentId = userUtil.getCurrentStudent().studentId
2827

29-
val isEmptyBetting = batchValidator.valid(matchId, studentId)
28+
val isEmptyBetting = batchValidator.valid(matchId, studentId, dto)
3029

3130
if (isEmptyBetting) {
3231
batchProcessor.emptyBettingBatch(matchId, dto, studentId, isEmptyBetting)
@@ -51,9 +50,8 @@ class BatchServiceImpl(
5150

5251
@Transactional
5352
override fun cancel(matchId: Long) {
54-
// 동시성 처리 필요
5553
val studentId = userUtil.getCurrentStudent().studentId
56-
val batch = batchReader.readByMatchId(matchId)
54+
val batch = batchReader.readByMatchIdForWrite(matchId)
5755
batchValidator.cancelValid(batch, matchId, studentId)
5856
batchProcessor.cancel(batch)
5957

0 commit comments

Comments
 (0)