Skip to content

Commit

Permalink
FU-63 feat: CI/CD을 위한 작업스크립트 deploy.yml 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yuseok0215 authored Jul 24, 2024
1 parent 990cf9b commit 40acbc4
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy to Amazon EC2

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

env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: cicd-backend-develop-bucket
AWS_CODE_DEPLOY_APPLICATION: cicd-develop-CD
AWS_CODE_DEPLOY_GROUP: cicd-develop-CD-group


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
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@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.CICD_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

0 comments on commit 40acbc4

Please sign in to comment.