✨: feat SQS Message Produce 실패에 대한 처리 구현 #70 #61
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
name: API Server Java CD with Gradle on DEV | |
# develop 브랜치에 push 시에 동작 | |
on: | |
push: | |
branches: [ "develop" ] | |
paths: # 아래 패키지에 변경사항이 있는 pull-request 만 동작 | |
- lionheart-api/** | |
- lionheart-domain/** | |
- lionheart-common/** | |
- lionheart-external/** | |
env: | |
S3_BUCKET_NAME: lionheart-s3 | |
jobs: | |
build: | |
name: Code deployment | |
# 실행 환경 | |
runs-on: ubuntu-latest | |
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' | |
# 3) AWS Secrets Manger 환경변수 사용 | |
- name: Read secrets from AWS Secrets Manager into environment variables | |
uses: abhilash1in/[email protected] | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_DEV }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_DEV }} | |
aws-region: ap-northeast-2 | |
secrets: /secret/lionheart-dev | |
parse-json: false | |
# build | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle # 실제 application build(-x 옵션을 통해 test는 제외) | |
run: ./gradlew lionheart-api:bootJar -x test | |
# 디렉토리 생성 | |
- name: Make Directory | |
run: mkdir -p deploy | |
# Jar 파일 복사 | |
- name: Copy Jar | |
run: cp ./lionheart-api/build/libs/*.jar ./deploy | |
# appspec.yml, script files 복사 | |
- name: Copy files | |
run: cp ./scripts/lionheart-api/* ./deploy | |
- name: Make zip file | |
run: zip -r ./lionheart-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_DEV }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_DEV }} | |
aws-region: ap-northeast-2 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./lionheart-api.zip s3://$S3_BUCKET_NAME/ | |
# Deploy (codeDeploy 변동 시, run 스크립트 수정) | |
- name: Deploy | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_DEV }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY_DEV }} | |
run: | |
aws deploy create-deployment | |
--application-name lionheart-codeDeploy | |
--deployment-group-name API_SERVER | |
--file-exists-behavior OVERWRITE | |
--s3-location bucket=lionheart-s3,bundleType=zip,key=lionheart-api.zip | |
--region ap-northeast-2 |