Skip to content

Commit

Permalink
Merge pull request #98 from Team-Umbba/fix/#95-notification_server_er…
Browse files Browse the repository at this point in the history
…ror_2

[FIX] Warning 해결을 위한 수정사항 반영
  • Loading branch information
ddongseop authored Aug 15, 2023
2 parents 5c762b0 + 7ca6425 commit 49af06f
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 98 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/api-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
distribution: 'temurin'

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
Expand Down Expand Up @@ -90,13 +90,6 @@ jobs:
- name: Make zip file
run: zip -r ./umbba-api.zip ./deploy
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./umbba-api.zip s3://$S3_BUCKET_NAME/
Expand Down
171 changes: 82 additions & 89 deletions .github/workflows/notification-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,92 +24,85 @@ jobs:

steps:

# 1) 워크플로우 실행 전 기본적으로 체크아웃 필요
- name: checkout
uses: actions/checkout@v3

# 2) JDK 11버전 설치, 다른 JDK 버전을 사용하다면 수정
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

# 3) 환경변수 파일 생성
- name: make application.yml 파일 생성
run: |
# application.yml 파일 생성
cd ./umbba-notification/src/main/resources
rm application.yaml
touch ./application.yml
# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.UMBBA_SECRET }}" >> ./application.yml
# 생성된 파일 확인
cat ./application.yml
####################################
# FCM secret key 폴더 생성
mkdir ./firebase
cd ./firebase
aws s3 cp --region ap-northeast-2 s3://${{ secrets.S3_BUCKET_NAME }}/json/umbba-fcm-firebase-adminsdk.json .
shell: bash

# 이 워크플로우는 gradle build
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle # 실제 application build(-x 옵션을 통해 test는 제외)
run: ./gradlew umbba-notification:bootJar -x test

# 디렉토리 생성
- name: Make Directory
run: mkdir -p deploy

# Jar 파일 복사
- name: Copy Jar
run: cp ./umbba-notification/build/libs/*.jar ./deploy
# run: cp -r src/main/* ./deploy

# appspec.yml, script files 파일 복사
- name: Copy files
run: cp ./scripts/umbba-notification/* ./deploy

- name: Make zip file
run: zip -r ./umbba-notification.zip ./deploy
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./umbba-notification.zip s3://$S3_BUCKET_NAME/

# Deploy
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
run:
aws deploy create-deployment
--application-name umbba-server-codedeploy
--deployment-group-name umbba-notification-server-codedeploy-group
--file-exists-behavior OVERWRITE
--s3-location bucket=umbba-storage,bundleType=zip,key=umbba-notification.zip
--region ap-northeast-2
# 1) 워크플로우 실행 전 기본적으로 체크아웃 필요
- name: checkout
uses: actions/checkout@v3

# 2) JDK 11버전 설치, 다른 JDK 버전을 사용하다면 수정
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

# 3) 환경변수 파일 생성
- name: make application.yml 파일 생성
run: |
# application.yml 파일 생성
cd ./umbba-notification/src/main/resources
rm application.yaml
touch ./application.yml
# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.UMBBA_SECRET }}" >> ./application.yml
# 생성된 파일 확인
cat ./application.yml
####################################
# FCM secret key 폴더 생성
mkdir ./firebase
cd ./firebase
aws s3 cp --region ap-northeast-2 s3://${{ secrets.S3_BUCKET_NAME }}/json/umbba-fcm-firebase-adminsdk.json .
shell: bash

# 이 워크플로우는 gradle build
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle # 실제 application build(-x 옵션을 통해 test는 제외)
run: ./gradlew umbba-notification:bootJar -x test

# 디렉토리 생성
- name: Make Directory
run: mkdir -p deploy

# Jar 파일 복사
- name: Copy Jar
run: cp ./umbba-notification/build/libs/*.jar ./deploy
# run: cp -r src/main/* ./deploy

# appspec.yml, script files 파일 복사
- name: Copy files
run: cp ./scripts/umbba-notification/* ./deploy

- name: Make zip file
run: zip -r ./umbba-notification.zip ./deploy
shell: bash

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./umbba-notification.zip s3://$S3_BUCKET_NAME/

# Deploy
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
run:
aws deploy create-deployment
--application-name umbba-server-codedeploy
--deployment-group-name umbba-notification-server-codedeploy-group
--file-exists-behavior OVERWRITE
--s3-location bucket=umbba-storage,bundleType=zip,key=umbba-notification.zip
--region ap-northeast-2
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ public void schedulePushAlarm(String cronExpression, Long parentchildId) {
throw new RuntimeException(e);
}

Parentchild parentchild = parentchildRepository.findById(parentchildId).get();
Parentchild parentchild = parentchildRepository.findById(parentchildId).orElseThrow(
() -> new CustomException(ErrorType.NOT_EXIST_PARENT_CHILD_RELATION)
);

TransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
TransactionStatus transactionStatus = transactionManager.getTransaction(transactionDefinition);
Expand Down

0 comments on commit 49af06f

Please sign in to comment.