Skip to content
Merged
56 changes: 52 additions & 4 deletions .github/workflows/docker-build-develop.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: develop 브랜치 도커 이미지 생성
name: develop 브랜치 Docker Build & 무중단 배포

on:
push:
Expand All @@ -8,6 +8,8 @@ on:
jobs:
build:
runs-on: ubuntu-latest
outputs:
docker_image: ${{ steps.docker.outputs.docker_image }}

steps:
- name: 리포지토리 체크아웃
Expand Down Expand Up @@ -38,14 +40,15 @@ jobs:

- name: GitHub Container Registry 로그인
run: |
export CR_PAT=${{ secrets.SIGNAL_BUDDY_TOKEN }}
export CR_PAT=${{ secrets.GIT_TOKEN }}
echo $CR_PAT | docker login ghcr.io -u ${{ secrets.GIT_ID }} --password-stdin


- name: 도커 이미지 생성
id: docker
run: |
TAG=$(git rev-parse --short HEAD)
DOCKER_IMAGE=${{ secrets.DOCKER_REGISTRY }}/signal-buddy:$TAG
echo "docker_image=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT"
docker build -t test -f submodule/docker/dev.Dockerfile .
docker tag test $DOCKER_IMAGE
docker push $DOCKER_IMAGE
Expand All @@ -61,4 +64,49 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --info --stacktrace
run: ./gradlew sonar --info --stacktrace

deploy:
runs-on: ubuntu-latest
needs: build

concurrency:
group: deploy
cancel-in-progress: true # 기존 실행 중인 워크플로우는 취소, 새 커밋 기준으로 실행

steps:
- name: GitHub Actions Runner의 Public IP 가져오기
id: ip
uses: haythem/public-ip@v1

- name: AWS credentials 설정
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_IAM_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_IAM_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: GitHub Actions IP를 인바운드 룰에 임시 추가
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SECURITY_GROUP_ID }} \
--protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32

- name: AWS EC2 SSH 접속 및 배포
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
set -e
echo ${{ secrets.GIT_TOKEN }} | docker login ghcr.io -u ${{ secrets.GIT_ID }} --password-stdin
docker pull ${{ needs.build.outputs.docker_image }}
echo 'DOCKER_IMAGE=${{ needs.build.outputs.docker_image }}' > ${{ secrets.SUBMODULE_DIRECTORY }}/docker/.env
sudo sh ${{ secrets.SUBMODULE_DIRECTORY }}/script/deploy.sh
docker system prune -a -f || true

- name: GitHub Actions Runner의 IP를 인바운드에서 삭제
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SECURITY_GROUP_ID }} \
--protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: GitHub Container Registry 로그인
run: |
export CR_PAT=${{ secrets.SIGNAL_BUDDY_TOKEN }}
export CR_PAT=${{ secrets.GIT_TOKEN }}
echo $CR_PAT | docker login ghcr.io -u ${{ secrets.GIT_ID }} --password-stdin


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public final class QueryDslUtils {
* @param endDate 조회하려는 끝 날짜 (null이면 없는 것으로 처리)
* @return 시작 날짜 ~ 끝 날짜 범위를 조건으로 설정하여 반환 (둘 다 null이면 전체 조회)
*/
public static BooleanExpression betweenDates(DateTimePath<LocalDateTime> path,
LocalDate startDate, LocalDate endDate) {
public static BooleanExpression betweenDates(
DateTimePath<LocalDateTime> path,
LocalDate startDate, LocalDate endDate
) {
BooleanExpression predicate = null;

if (startDate != null) {
Expand All @@ -57,8 +59,11 @@ public static BooleanExpression betweenDates(DateTimePath<LocalDateTime> path,
* @throws org.springframework.dao.InvalidDataAccessApiUsageException 잘못된 필드명을 입력하면 쿼리를 처리하는 중
* 해당 예외가 발생한다.
*/
public static OrderSpecifier<?>[] getOrderSpecifiers(Pageable pageable, Class<?> type,
String variable) {
public static OrderSpecifier<?>[] getOrderSpecifiers(
Pageable pageable,
Class<?> type,
String variable
) {
List<OrderSpecifier<?>> orderSpecifiers = new ArrayList<>();

// 정렬 조건이 없는 경우
Expand All @@ -76,8 +81,7 @@ public static OrderSpecifier<?>[] getOrderSpecifiers(Pageable pageable, Class<?>
}

@SuppressWarnings("unchecked")
OrderSpecifier<?>[] results = orderSpecifiers.toArray(
new OrderSpecifier<?>[0]);
OrderSpecifier<?>[] results = orderSpecifiers.toArray(new OrderSpecifier<?>[0]);
return results;
}

Expand All @@ -89,12 +93,15 @@ public static OrderSpecifier<?>[] getOrderSpecifiers(Pageable pageable, Class<?>
* @param target2 타켓 컬럼 2
* @return QueryDSL에서 Where의 조건으로 사용
*/
public static BooleanExpression fulltextSearch(String keyword, StringPath target1, StringPath target2) {
public static BooleanExpression fulltextSearch(
String keyword,
StringPath target1, StringPath target2
) {
if (keyword == null || keyword.isBlank()) {
return Expressions.TRUE;
}

String formattedSearchWord = "\"" + keyword + "\"";
String formattedSearchWord = keyword + "*";
return numberTemplate(
Double.class, "function('match2_against', {0}, {1}, {2})",
target1, target2, formattedSearchWord
Expand All @@ -113,7 +120,7 @@ public static BooleanExpression fulltextSearch(String keyword, StringPath target
return Expressions.TRUE;
}

String formattedSearchWord = "\"" + keyword + "\"";
String formattedSearchWord = keyword + "*";
return numberTemplate(
Double.class, "function('match_against', {0}, {1})",
target, formattedSearchWord
Expand Down