Skip to content

Feature: CI/CD 기능 구현 (#42) #32

Feature: CI/CD 기능 구현 (#42)

Feature: CI/CD 기능 구현 (#42) #32

Workflow file for this run

name: CI
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
env:
PROJECT_NAME: CS-Quiz-BE
BUCKET_NAME: cotato-ci-cd-bucket
CODE_DEPLOY_APP_NAME: cotato-server
DEPLOYMENT_GROUP_NAME: cotato-server-deploy
jobs:
build:
runs-on: ubuntu-latest
steps:
# [0] JDK 세팅
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
# [1] Set up Yaml File
# - name: Set up Yaml File
# [2] 실행 권한 부여
- name: Grant permission for gradlew
run: chmod +x ./gradlew
shell: bash
# [3] 프로젝트 빌드
- name: Build with Gradle Wrapper
run: ./gradlew build
# [4] Zip 파일 만들기
- name: Make Zip File
run: zip -r $GITHUB_SHA.zip .
shell: bash
# [5] AWS 키 설정
- 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_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
# [6] 빌드한 jar파일 S3업로드
- name: Upload to s3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ env.BUCKET_NAME }}/${{ env.PROJECT_NAME }}/$GITHUB_SHA.zip
# [7] CodeDeploy에 S3에서 jar 파일을 받아라
- name: Code Deploy
run: aws deploy create-deployment \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--application-name ${{ env.CODE_DEPLOY_APP_NAME }} \
--deployment-group-name ${{ env.DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip