diff --git a/.github/workflows/prod-ci.yml b/.github/workflows/ci.yml similarity index 85% rename from .github/workflows/prod-ci.yml rename to .github/workflows/ci.yml index f215b66..d39288f 100644 --- a/.github/workflows/prod-ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,9 @@ -name: prod-CI +name: CI on: pull_request: - branches: [ "main" ] + branches: + - '*' jobs: build: @@ -10,7 +11,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true token: ${{ secrets.SUBMODULE_TOKEN }} diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml deleted file mode 100644 index b881487..0000000 --- a/.github/workflows/dev-ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: develop-CI - -on: - pull_request: - branches: [ "develop" ] - -jobs: - build: - runs-on: ubuntu-22.04 - - steps: - - name: checkout - uses: actions/checkout@v3 - with: - submodules: true - token: ${{ secrets.SUBMODULE_TOKEN }} - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: '17' - - - name: build - run: | - chmod +x gradlew - ./gradlew build -x test - shell: bash \ No newline at end of file diff --git a/.github/workflows/prod-cd.yml b/.github/workflows/prod-cd.yml index 14df26f..1fbab71 100644 --- a/.github/workflows/prod-cd.yml +++ b/.github/workflows/prod-cd.yml @@ -9,10 +9,9 @@ jobs: env: working-directory: . - steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true token: ${{ secrets.SUBMODULE_TOKEN }} @@ -60,3 +59,33 @@ jobs: script: | cd ~ ./deploy.sh + + create-release: + needs: cd + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + + - name: 버전 정보 추출 + id: extract_version_name + run: | + VERSION=$(echo "${{ github.event.head_commit.message }}" | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -n1 | tr -d '[:space:]') + + if [ -z "$VERSION" ]; then + echo "No version found in the commit message." + exit 1 + fi + + - name: Create GitHub Release + run: | + response=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.SUBMODULE_TOKEN }}" \ + https://api.github.com/repos/OMZigak/KKUMER/releases \ + -d '{"tag_name":"${{ steps.extract_version_name.outputs.version }}","target_commitish":"main","name":"${{ steps.extract_version_name.outputs.version }}","generate_release_notes":true}') + + if [ "$response" -ne 201 ]; then + echo "GitHub Release failed with status code $response" + exit 1 + fi \ No newline at end of file diff --git a/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java b/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java index 03acbf7..939266c 100644 --- a/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java +++ b/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java @@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.kkumulkkum.server.domain.Meeting; import org.kkumulkkum.server.domain.Member; +import org.kkumulkkum.server.domain.Promise; import org.kkumulkkum.server.dto.meeting.MeetingMetCountDto; import org.kkumulkkum.server.dto.meeting.request.MeetingCreateDto; import org.kkumulkkum.server.dto.meeting.request.MeetingRegisterDto; @@ -18,7 +19,9 @@ import org.kkumulkkum.server.service.member.MemberRetreiver; import org.kkumulkkum.server.service.member.MemberSaver; import org.kkumulkkum.server.service.participant.ParticipantRemover; +import org.kkumulkkum.server.service.participant.ParticipantRetriever; import org.kkumulkkum.server.service.promise.PromiseRemover; +import org.kkumulkkum.server.service.promise.PromiseRetriever; import org.kkumulkkum.server.service.user.UserRetriever; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -41,6 +44,8 @@ public class MeetingService { private final MemberRemover memberRemover; private final PromiseRemover promiseRemover; private final MeetingRemover meetingRemover; + private final PromiseRetriever promiseRetriever; + private final ParticipantRetriever participantRetriever; @Transactional public CreatedMeetingDto createMeeting( @@ -127,6 +132,9 @@ public void leaveMeeting( promiseRemover.deleteByMeetingId(meetingId); meetingRemover.deleteById(meetingId); } + + //모임 내의 약속들 모두 돌려서, 거기서 참여자가 없는 약속이 있다면 지우기 + removeEmptyPromises(meetingId); } private String generateInvitationCode() { @@ -152,4 +160,10 @@ private String generateRandomCode() { return codeBuilder.toString(); } + private void removeEmptyPromises(final Long meetingId) { + promiseRetriever.findAllByMeetingId(meetingId).stream() + .filter(promise -> participantRetriever.findAllByPromiseId(promise.getId()).isEmpty()) + .forEach(promise -> promiseRemover.deleteById(promise.getId())); + } + } diff --git a/src/main/java/org/kkumulkkum/server/service/promise/PromiseService.java b/src/main/java/org/kkumulkkum/server/service/promise/PromiseService.java index 43ff55b..3f42feb 100644 --- a/src/main/java/org/kkumulkkum/server/service/promise/PromiseService.java +++ b/src/main/java/org/kkumulkkum/server/service/promise/PromiseService.java @@ -230,5 +230,4 @@ private void removeOldParticipants( }).toList() ); } - }