Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jhhong0509 committed Jun 24, 2022
2 parents 98f9a58 + 12fd62e commit e717838
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 7 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/prod-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build for Prod
on:
push:
tags:
- v*.*.*

env:
SERVICE_NAME: user
SERVICE_TYPE: be

jobs:
build:
environment: prod
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 17 ]
outputs:
version: ${{ steps.get_version.outputs.BRANCH_NAME }}

steps:
- name: Check Out The Repository
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java-version }}
distribution: 'zulu'

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)

- name: Gradle Build
uses: gradle/gradle-build-action@v2
with:
arguments: |
build
--no-daemon
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{secrets.DOCKER_USER}}
password: ${{secrets.DOCKER_HUB_TOKEN}}

- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: ./Dockerfile
push: true
tags: ${{secrets.DOCKER_USER}}/${{env.SERVICE_NAME}}-${{env.SERVICE_TYPE}}:${{ steps.get_version.outputs.VERSION }}
build-args: |
DBMS=${{secrets.DBMS_PROD}}
DB_HOST=${{secrets.DB_HOST_PROD}}
DB_PORT=${{secrets.DB_PORT_PROD}}
DB_NAME=${{secrets.DB_NAME_PROD}}
DB_PASSWORD=${{secrets.DB_PASSWORD_PROD}}
DB_USERNAME=${{secrets.DB_USERNAME_PROD}}
SHOW_SQL=${{secrets.SHOW_SQL_PROD}}
DDL_AUTO_MODE=${{secrets.DDL_AUTO_MODE_PROD}}
DB_POOL=${{secrets.DB_POOL_PROD}}
AUTHORITY_SERVICE_HOST=${{secrets.AUTHORITY_SERVICE_HOST}}
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITOPS_DEPLOY_PRODUCTION_TOKEN }}
repository: team-xquare/xquare-gitops-repo-production
event-type: update_image
client-payload: '{
"ref": "${{ github.ref }}",
"version": "${{ steps.get_version.outputs.VERSION }}",
"service_name": "${{env.SERVICE_NAME}}",
"service_type": "${{env.SERVICE_TYPE}}"
}'
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ data class User(
fun setUserStateToCreated(): User {
return copy(state = UserState.CREATED)
}

fun setDeviceToken(deviceToken: String): User {
return copy(deviceToken = deviceToken)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package com.xquare.v1userservice.user.api.dtos

data class SignInDomainRequest(
val accountId: String,
val password: String
val password: String,
val deviceToken: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ class UserSignInApiImpl(
val user = userRepositorySpi.findByAccountIdAndStateWithCreated(signInDomainRequest.accountId)
?: throw UserNotFoundException(UserNotFoundException.USER_ID_NOT_FOUND)

checkPasswordMatches(user, signInDomainRequest.password)
val authorities = authorityListSpi.getAuthorities(user.id)
val deviceTokenModifiedUser = userRepositorySpi.applyChanges(user.setDeviceToken(signInDomainRequest.deviceToken))

checkPasswordMatches(deviceTokenModifiedUser, signInDomainRequest.password)
val authorities = authorityListSpi.getAuthorities(deviceTokenModifiedUser.id)

val params = HashMap<String, Any>()
.apply {
put("authorities", authorities)
put("role", user.role)
put("role", deviceTokenModifiedUser.role)
}

val accessToken = jwtTokenGeneratorSpi.generateJwtToken(signInDomainRequest.accountId, TokenType.ACCESS_TOKEN, params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class UserHandler(
private fun SignInRequest.toDomainRequest() =
SignInDomainRequest(
accountId = this.accountId,
password = this.password
password = this.password,
deviceToken = this.deviceToken
)

suspend fun getUserByIdHandler(serverRequest: ServerRequest): ServerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ data class SignInRequest(
@field:NotNull
val accountId: String,
@field:NotNull
val password: String
val password: String,
@field:NotNull
val deviceToken: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ internal class UserRouterTest(

private fun buildUserSignInRequest() = SignInRequest(
accountId = "test",
password = "test"
password = "test",
deviceToken = "test"
)

private fun sendSignInRequestWithBody(signInRequest: SignInRequest) =
Expand Down

0 comments on commit e717838

Please sign in to comment.