Merge pull request #108 from MacroSoft-Team/docs/#107/readmeEdit #73
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: Deploy to Amazon EC2 | |
on: | |
push: | |
branches: | |
- develop | |
env: | |
AWS_REGION: ap-northeast-2 | |
AWS_S3_BUCKET: modak | |
AWS_CODE_DEPLOY_APPLICATION: modakDA | |
AWS_CODE_DEPLOY_GROUP: modak-DA-Group | |
jobs: | |
build-with-gradle: | |
runs-on: ubuntu-latest | |
steps: | |
- name: develop 브랜치로 이동 및 서브모듈 초기화 | |
uses: actions/checkout@v4 | |
with: | |
ref: develop | |
submodules: true | |
token: ${{ secrets.SUBMODULE_ACCESS_TOKEN }} | |
- name: JDK 17 설치 | |
uses: actions/[email protected] | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
- name: gradlew 에 실행 권한 부여 | |
run: chmod +x ./gradlew | |
- name: 프로젝트 빌드 | |
run: ./gradlew clean build -x test | |
- name: AWS credential 설정 | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.IAM_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.IAM_SECRET_KEY }} | |
- name: S3에 업로드 | |
run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://$AWS_S3_BUCKET/cicdtest/$GITHUB_SHA.zip --source . | |
- name: EC2에 배포 | |
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,key=cicdtest/$GITHUB_SHA.zip,bundleType=zip |