Skip to content

Commit

Permalink
✨ Add CI file
Browse files Browse the repository at this point in the history
github action 설정을 위한 yml 재작성
  • Loading branch information
min-0 authored Jul 29, 2024
1 parent 433a855 commit abba964
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: mapddang-s3
AWS_CODE_DEPLOY_APPLICATION: mapddang-CD
AWS_CODE_DEPLOY_GROUP: mapddang-CD-group

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'
#Gradle 설정
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
#gradlew 파일에 실행 권한 부여
- name: Grant execute permission to gradlew
run: chmod +x ./gradlew
#프로젝트 빌드(test 제외)
- 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 }}
aws-secret-access-key: ${{ secrets.EC2_SECRET_KEY }}
aws-region: ap-northeast-2
#ZIP 파일로 압축(.git 제외)
- name: Create ZIP file
run: zip -r release.zip . -x "*.git*"
#ZIP 파일을 S3 버킷에 업로드
- name: Upload to AWS S3
run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} \
--ignore-hidden-files --s3-location s3://${{ env.AWS_S3_BUCKET }}/cicdtest/${{ 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=${{ env.AWS_S3_BUCKET }},key=cicdtest/${{ github.sha }}.zip,bundleType=zip

0 comments on commit abba964

Please sign in to comment.