Merge pull request #193 from Team-Blitz-Steady/feat/#183 #129
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: 블리츠 백엔드 서버 CD | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
env: | |
PROJECT_NAME: blitz-dev-server | |
BUCKET_NAME: team13a-cicd-bucket | |
CODE_DEPLOY_APP_NAME: team13a-cp | |
DEPLOYMENT_GROUP_NAME: team13a-cp-group | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GIT_TOKEN }} | |
submodules: 'true' | |
- name: JDK 17 설치 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: gradlew 권한 부여 | |
run: chmod +x ./gradlew | |
shell: bash | |
- name: 빌드 & 테스트 | |
run: ./gradlew build test | |
- name: Zip 파일 생성 | |
run: zip -qq -r ./$GITHUB_SHA.zip . | |
shell: bash | |
- name: AWS 정보 (ec2) 설정 | |
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: Zip 파일 S3로 업로드 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip | |
- name: EC2 인스턴스로 코드 디플로이 배포 | |
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 | |
- name: CD 결과 알림 | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
author_name: CD 결과 알림 | |
fields: repo, message, commit, author, action, eventName, ref, workflow, job, took | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
if: always() |