-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'be/develop' of https://github.com/woowacourse-teams/202…
…4-pokerogue-helper into feat/#364-data-test
- Loading branch information
Showing
28 changed files
with
533 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Backend Production Server CD | ||
|
||
on: | ||
push: | ||
branches: [ "be/release" ] | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/Backend-CI.yml | ||
secrets: inherit | ||
|
||
|
||
build: | ||
needs: test | ||
runs-on: [cd, app-b] | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.ACTION_TOKEN }} | ||
submodules: true | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew bootJar | ||
working-directory: ./backend/pokerogue | ||
|
||
- name: Docker build and push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t ${{ secrets.DOCKER_SERVER_IMAGE }} -f ./backend/pokerogue/docker/Dockerfile ./backend/pokerogue | ||
docker push ${{ secrets.DOCKER_SERVER_IMAGE }} | ||
|
||
deploy: | ||
needs: build | ||
runs-on: [cd, app-b] | ||
steps: | ||
|
||
- name: Change permission | ||
run: | | ||
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/2024-pokerogue-helper | ||
- name: Deploy | ||
run: | | ||
cd /home/ubuntu | ||
sudo chmod 666 /var/run/docker.sock | ||
if [ "$(docker ps -qa -f name=server)" ]; then | ||
docker rm -f server | ||
else | ||
echo "No container named 'server' to remove." | ||
fi | ||
docker pull ${{ secrets.DOCKER_SERVER_IMAGE }} | ||
docker run -d -p 80:8080 --name server \ | ||
-e JAVA_OPTS="-XX:InitialRAMPercentage=70.0 -XX:MaxRAMPercentage=70.0" \ | ||
-e TZ=Asia/Seoul \ | ||
${{ secrets.DOCKER_SERVER_IMAGE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...e/src/main/java/com/pokerogue/helper/biome/converter/SortingCriteriaRequestConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.pokerogue.helper.biome.converter; | ||
|
||
import com.pokerogue.helper.global.constant.SortingCriteria; | ||
import org.springframework.core.convert.converter.Converter; | ||
|
||
public class SortingCriteriaRequestConverter implements Converter<String, SortingCriteria> { | ||
|
||
@Override | ||
public SortingCriteria convert(String sortingCriteriaValue) { | ||
return SortingCriteria.convertFrom(sortingCriteriaValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...d/pokerogue/src/main/java/com/pokerogue/helper/biome/service/NativePokemonComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.pokerogue.helper.biome.service; | ||
|
||
import static com.pokerogue.helper.global.constant.SortingCriteria.ASCENDING; | ||
import static com.pokerogue.helper.global.constant.SortingCriteria.DESCENDING; | ||
|
||
import com.pokerogue.helper.biome.data.NativePokemon; | ||
import com.pokerogue.helper.global.constant.SortingCriteria; | ||
import java.util.Comparator; | ||
|
||
public class NativePokemonComparator implements Comparator<NativePokemon> { | ||
|
||
private static final NativePokemonComparator ASCENDING_COMPARATOR = new NativePokemonComparator(ASCENDING); | ||
private static final NativePokemonComparator DESCENDING_COMPARATOR = new NativePokemonComparator(DESCENDING); | ||
|
||
private final SortingCriteria criteria; | ||
|
||
private NativePokemonComparator(SortingCriteria criteria) { | ||
this.criteria = criteria; | ||
} | ||
|
||
public static NativePokemonComparator of(SortingCriteria criteria) { | ||
if (criteria.equals(ASCENDING)) { | ||
return ASCENDING_COMPARATOR; | ||
} | ||
|
||
return DESCENDING_COMPARATOR; | ||
} | ||
|
||
@Override | ||
public int compare(NativePokemon firstPokemon, NativePokemon secondPokemon) { | ||
if (this.criteria.equals(ASCENDING)) { | ||
return Integer.compare(firstPokemon.getRarity(), secondPokemon.getRarity()); | ||
} | ||
|
||
return Integer.compare(secondPokemon.getRarity(), firstPokemon.getRarity()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
backend/pokerogue/src/main/java/com/pokerogue/helper/global/config/WebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.pokerogue.helper.global.config; | ||
|
||
import com.pokerogue.helper.biome.converter.SortingCriteriaRequestConverter; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.format.FormatterRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addFormatters(FormatterRegistry registry) { | ||
registry.addConverter(new SortingCriteriaRequestConverter()); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/pokerogue/src/main/java/com/pokerogue/helper/global/constant/SortingCriteria.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.pokerogue.helper.global.constant; | ||
|
||
import com.pokerogue.helper.global.exception.ErrorMessage; | ||
import com.pokerogue.helper.global.exception.GlobalCustomException; | ||
import java.util.Arrays; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum SortingCriteria { | ||
|
||
ASCENDING("asc"), | ||
DESCENDING("desc"), | ||
; | ||
|
||
private final String value; | ||
|
||
SortingCriteria(String value) { | ||
this.value = value; | ||
} | ||
|
||
public static SortingCriteria convertFrom(String value) { | ||
return Arrays.stream(values()) | ||
.filter(criteria -> criteria.value.equals(value)) | ||
.findAny() | ||
.orElseThrow(() -> new GlobalCustomException(ErrorMessage.INVALID_SORTING_CRITERIA)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.