chore: cd 작업 설정 #85
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: Java CI with Gradle | |
on: | |
pull_request: | |
branches: | |
- main | |
env: | |
PROJECT_NAME: feed-project | |
BUCKET_NAME: feed-cd-bucket | |
CODE_DEPLOY_APP_NAME: feed_cd | |
DEPLOYMENT_GROUP_NAME: feed_instance | |
permissions: | |
contents: read | |
checks: write | |
pull-requests: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 체크아웃 | |
uses: actions/checkout@v4 | |
- name: JDK 17 설치 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'corretto' | |
- name: 빌드 권한 부여 | |
run: chmod +x gradlew | |
- name: 프로젝트 빌드 | |
run: ./gradlew clean build | |
- name: 자코코 리포트 작성 | |
uses: madrapps/[email protected] | |
with: | |
title: 📊 Jacoco Test Coverage | |
paths: ${{ github.workspace }}/**/build/reports/jacoco/test/jacocoTestReport.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
min-coverage-overall: 0 | |
min-coverage-changed-files: 0 | |
- name: 테스트 리포트 작성 | |
uses: mikepenz/action-junit-report@v4 | |
with: | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
- name: 디스코드 알림 | |
uses: tsickert/[email protected] | |
if: success() | |
with: | |
webhook-url: ${{ secrets.WEBHOOK_URL }} | |
content: ":love_letter: 새로운 PR이 날아왔습니다 ~ :love_letter:\n:link: 리뷰하러 가기: ${{ github.event.pull_request.html_url }}" | |
- name: ZIP 파일 생성 | |
run: zip -qq -r ./$GITHUB_SHA.zip . | |
shell: bash | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip | |
- name: Code Deploy To EC2 instance | |
run: aws deploy create-deployment | |
--application-name $CODE_DEPLOY_APP_NAME | |
--deployment-config-name CodeDeployDefault.AllAtOnce | |
--deployment-group-name $DEPLOYMENT_GROUP_NAME | |
--s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip |