Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 배포 버전 workflow 추가 구성 #322

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/develop-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Develop Deploy

on:
workflow_dispatch:
inputs:
commit_hash:
description: 'commit_hash'
required: true

env:
DOCKERHUB_IMAGE_NAME: walwal-server

jobs:
build-deploy:
runs-on: ubuntu-latest
environment: DEV
steps:
# EC2로 배포
- name: Deploy to EC2 Server
uses: appleboy/[email protected]
env:
IMAGE_FULL_URL: ${{ steps.metadata.outputs.tags }}
DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
envs: IMAGE_FULL_URL, DOCKERHUB_IMAGE_NAME # docker-compose.yml 에서 사용할 환경 변수
debug: true
script: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
docker compose up -d
docker exec -d nginx nginx -s reload
docker image prune -a -f

## Slack
- name: Slack Alarm
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: GitHub-Actions CI/CD
fields: repo,message,commit,author,ref,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.
44 changes: 44 additions & 0 deletions .github/workflows/production-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Production Deploy

on:
workflow_dispatch:
inputs:
version:
description: 'version'
required: true

env:
DOCKERHUB_IMAGE_NAME: walwal-server

jobs:
build-deploy:
runs-on: ubuntu-latest
environment: PROD
steps:
- name: Deploy to EC2 Server
uses: appleboy/ssh-action@master
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
IMAGE_FULL_URL: ${{ steps.metadata.outputs.tags }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
envs: IMAGE_FULL_URL # docker-compose.yaml 에서 사용할 환경 변수
script: |
aws s3 cp ${{ env.S3_COPY_PATH }} docker-compose.yaml
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
docker pull ${{ env.IMAGE_FULL_URL }}
docker compose up -d
docker image prune -a -f

## Slack
- name: Slack Alarm
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: GitHub-Actions CI/CD
fields: repo,message,commit,author,ref,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,19 @@ private CommentFindOneResponse convertToCommentFindOneResponse(
.collect(Collectors.toList());

// 작성자가 null인지 확인
Long writerId =
comment.getWriter().getStatus() != MemberStatus.DELETED
? comment.getWriter().getId()
: null;
String writerNickname =
comment.getWriter().getStatus() != MemberStatus.DELETED
? comment.getWriter().getProfile().getNickname()
: "탈퇴한 회원";
String writerProfileImageUrl =
comment.getWriter().getStatus() != MemberStatus.DELETED
? comment.getWriter().getProfile().getProfileImageUrl()
: "INACTIVE_" + comment.getWriter().getRaisePet().getValue();
Long writerId = null;
String writerNickname = "탈퇴한 회원";
String writerProfileImageUrl = null;

if (comment.getWriter() != null) {
if (comment.getWriter().getStatus() != MemberStatus.DELETED) {
writerId = comment.getWriter().getId();
writerNickname = comment.getWriter().getProfile().getNickname();
writerProfileImageUrl = comment.getWriter().getProfile().getProfileImageUrl();
} else {
writerProfileImageUrl = "INACTIVE_" + comment.getWriter().getRaisePet().getValue();
}
}

return CommentFindOneResponse.of(
comment.getParent() != null ? comment.getParent().getId() : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.depromeet.stonebed.domain.fcm.application.FcmNotificationService;
import com.depromeet.stonebed.domain.fcm.dao.FcmTokenRepository;
import com.depromeet.stonebed.domain.member.domain.Member;
import com.depromeet.stonebed.domain.member.domain.MemberStatus;
import com.depromeet.stonebed.domain.missionRecord.dao.MissionRecordRepository;
import com.depromeet.stonebed.domain.missionRecord.domain.MissionRecord;
import com.depromeet.stonebed.global.util.MemberUtil;
Expand Down Expand Up @@ -296,7 +297,11 @@ private Comment createMockComment(
String childContentPrefix = "자식 댓글 내용 ";

// 부모 댓글 생성
Member member = fixtureMonkey.giveMeOne(Member.class);
Member member =
fixtureMonkey
.giveMeBuilder(Member.class)
.set("status", MemberStatus.NORMAL)
.sample();
MissionRecord missionRecord = fixtureMonkey.giveMeOne(MissionRecord.class);
Comment parentComment = createMockParentComment(member, missionRecord, parentContent);

Expand Down Expand Up @@ -327,6 +332,7 @@ private Comment createMockComment(
assertEquals(1, result.comments().size(), "부모 댓글은 하나만 있어야 합니다.");

CommentFindOneResponse parentResponse = result.comments().get(0);

assertEquals(parentComment.getId(), parentResponse.commentId(), "부모 댓글 ID가 일치해야 합니다.");
assertEquals(parentComment.getContent(), parentResponse.content(), "부모 댓글 내용이 일치해야 합니다.");
assertEquals(
Expand Down
Loading