Skip to content

✨ AWS CloudWatch 설정 #135

✨ AWS CloudWatch 설정

✨ AWS CloudWatch 설정 #135

Workflow file for this run

name: Mapddang-Dev
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: mapddang-test-s3
AWS_CODE_DEPLOY_APPLICATION: mapddang-test
AWS_CODE_DEPLOY_GROUP: mapddang-test-group
MYSQL_URL_DEV: ${{ secrets.MYSQL_URL_DEV }}
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
APPLE_CLIENT_ID_DEV: ${{ secrets.APPLE_CLIENT_ID_DEV }}
APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_PRIVATE_KEY: ${{ secrets.APPLE_PRIVATE_KEY }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
ACCESS_TOKEN_EXPIRE_DEV: ${{ secrets.ACCESS_TOKEN_EXPIRE_DEV }}
REFRESH_TOKEN_EXPIRE_DEV: ${{ secrets.REFRESH_TOKEN_EXPIRE_DEV }}
EC2_ACCESS_KEY_DEV: ${{ secrets.EC2_ACCESS_KEY_DEV }}
EC2_SECRET_KEY_DEV: ${{ secrets.EC2_SECRET_KEY_DEV }}
AWS_BUCKET_NAME_DEV: ${{ secrets.AWS_BUCKET_NAME_DEV }}
jobs:
build-with-gradle:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# 체크아웃
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
#JDK 17 설정
java-version: '17'
distribution: 'corretto'
#gradlew 파일에 실행 권한 부여
- name: Grant execute permission to gradlew
run: chmod +x ./gradlew
#프로젝트 빌드
- name: Build Project
run: ./gradlew clean build -x test
#AWS 자격증명 설정
- name: Setup AWS credential
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.EC2_ACCESS_KEY_DEV }}
aws-secret-access-key: ${{ secrets.EC2_SECRET_KEY_DEV }}
aws-region: ap-northeast-2
#ZIP 파일을 S3 버킷에 업로드
- name: Upload to AWS S3
run: |
aws deploy push \
--application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} \
--ignore-hidden-files \
--s3-location s3://$AWS_S3_BUCKET/cicd/$GITHUB_SHA.zip \
--source .
#업로드된 ZIP 파일을 CodeDeploy로 배포
- name: AWS Code Deploy
run: |
aws deploy create-deployment \
--application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} \
--s3-location bucket=$AWS_S3_BUCKET,bundleType=zip,key=cicd/$GITHUB_SHA.zip