Skip to content

Commit

Permalink
Merge pull request #100 from soma-baekgu/feature/BG-381-cd-fix
Browse files Browse the repository at this point in the history
[BG-381]: cd ecr 로그인 문제 해결 (0.2h / 2h)
  • Loading branch information
GGHDMS authored Aug 25, 2024
2 parents b46530d + d27a3ed commit 5fe597c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci-cd-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
envs: APP, COMPOSE
script_stop: true
script: |
ssh api1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}"
ssh api1 docker-compose -f $COMPOSE down
ssh api1 docker pull ${{secrets.IMAGE_API}}
ssh api1 docker-compose -p api -f $COMPOSE up -d
Expand Down Expand Up @@ -178,6 +179,7 @@ jobs:
envs: APP, COMPOSE
script_stop: true
script: |
ssh notification1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}"
ssh notification1 docker-compose -f $COMPOSE down
ssh notification1 docker pull ${{secrets.IMAGE_NOTIFICATION}}
ssh notification1 docker-compose -p notification -f $COMPOSE up -d
Expand Down Expand Up @@ -264,6 +266,7 @@ jobs:
envs: APP, COMPOSE
script_stop: true
script: |
ssh batch1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}"
ssh batch1 docker-compose -f $COMPOSE down
ssh batch1 docker pull ${{secrets.IMAGE_BATCH}}
ssh batch1 docker-compose -p batch -f $COMPOSE up -d
Expand Down Expand Up @@ -350,6 +353,7 @@ jobs:
envs: APP, COMPOSE
script_stop: true
script: |
ssh realtime1 "aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REGISTRY }}"
ssh realtime1 docker-compose -f $COMPOSE down
ssh realtime1 docker pull ${{secrets.IMAGE_REALTIME}}
ssh realtime1 docker-compose -p realtime -f $COMPOSE up -d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.backgu.amaker.api.user.dto.UserDto
import com.backgu.amaker.domain.chat.ChatType
import com.backgu.amaker.domain.chat.ChatWithUser
import com.backgu.amaker.domain.chat.DefaultChatWithUser
import com.backgu.amaker.domain.event.EventWithUser
import com.backgu.amaker.domain.chat.EventChatWithUser
import java.time.LocalDateTime

sealed interface ChatWithUserDto<T> {
Expand All @@ -31,11 +31,11 @@ sealed interface ChatWithUserDto<T> {
user = UserDto.of(chatWithUser.user),
)

else ->
is EventChatWithUser ->
EventChatWithUserDto(
id = chatWithUser.id,
chatRoomId = chatWithUser.chatRoomId,
content = EventWithUserDto.of(chatWithUser.content as EventWithUser),
content = EventWithUserDto.of(chatWithUser.content),
chatType = chatWithUser.chatType,
createdAt = chatWithUser.createdAt,
updatedAt = chatWithUser.updatedAt,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.backgu.amaker.api.chat.dto.response

import com.backgu.amaker.api.chat.dto.ChatWithUserDto
import com.backgu.amaker.api.chat.dto.DefaultChatWithUserDto
import com.backgu.amaker.api.chat.dto.EventChatWithUserDto
import com.backgu.amaker.api.user.dto.response.UserResponse
import com.backgu.amaker.domain.chat.ChatType
Expand Down Expand Up @@ -32,7 +33,7 @@ interface ChatWithUserResponse<T> {
fun of(chatWithUserDto: ChatWithUserDto<*>): ChatWithUserResponse<*> =
when (chatWithUserDto) {
is EventChatWithUserDto -> EventChatWithUserResponse.of(chatWithUserDto)
else -> DefaultChatWithUserResponse.of(chatWithUserDto)
is DefaultChatWithUserDto -> DefaultChatWithUserResponse.of(chatWithUserDto)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ class ChatFacadeService(
chatUserCacheFacadeService.findChat(chatRoomId, it)
}

if (cachedChat != null) return ChatWithUserDto.of(cachedChat)
if (cachedChat != null) {
markMostRecentChatAsRead(chatRoomId, userId)
return ChatWithUserDto.of(cachedChat)
}

val chat = chatQueryService.getOneWithUser(chatRoomUser.lastReadChatId)
val chat =
chatQueryService.getOneWithUser(
chatRoomUser.lastReadChatId ?: chatRoomService.getById(chatRoomId).lastChatId,
)

if (!ChatType.isEventChat(chat.chatType)) return DefaultChatWithUserDto.of(chat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.backgu.amaker.domain.chat
import com.backgu.amaker.domain.user.User
import java.time.LocalDateTime

interface ChatWithUser<T> {
sealed interface ChatWithUser<T> {
val id: Long
val chatRoomId: Long
val content: T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Workspace(

fun createDefaultChatRoom(): ChatRoom = ChatRoom(workspaceId = id, name = "일반 채팅", chatRoomType = ChatRoomType.DEFAULT)

override fun toString(): String {
return "Workspace(id=$id, name='$name', thumbnail='$thumbnail', belongingNumber=$belongingNumber, workspacePlan=$workspacePlan)"
}
override fun toString(): String =
"Workspace(id=$id, name='$name', thumbnail='$thumbnail', belongingNumber=$belongingNumber, workspacePlan=$workspacePlan)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class ChatUserCacheFacadeService(
userCacheService.save(fetchedUser)
}

when (chat) {
is DefaultChatWithUserCache -> return chat.toDomain(user)
return when (chat) {
is DefaultChatWithUserCache -> chat.toDomain(user)
is EventChatWithUserCache -> {
val userIds = chat.content.users
val cachedUsers = userCacheService.findAllByUserIds(userIds)
Expand All @@ -68,7 +68,7 @@ class ChatUserCacheFacadeService(
userService.getAllByUserIds(missingUserIds).onEach { userCacheService.save(it) }
val allUsers = cachedUsers + fetchedUsers

return chat.toDomain(user, chat.content.toDomain(allUsers))
chat.toDomain(user, chat.content.toDomain(allUsers))
}
}
}
Expand Down Expand Up @@ -150,10 +150,6 @@ class ChatUserCacheFacadeService(

return chat.toDomain(user, chat.content.toDomain(allUsers))
}

else -> {
throw IllegalArgumentException("Invalid chat type")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class WorkspaceService(

@Transactional
fun updateBelonging(workspace: Workspace) {
workspaceRepository.updateBelongingWithLimit(workspace.id, workspace.workspacePlan.belongingLimit) != 1 &&
workspaceRepository.updateBelongingWithLimit(
workspace.id,
workspace.workspacePlan.belongingLimit,
) != 1 &&
throw BusinessException(StatusCode.INVALID_WORKSPACE_JOIN)
}

Expand Down

0 comments on commit 5fe597c

Please sign in to comment.