Skip to content

Commit

Permalink
#7 fix: deploy.yml 스텝 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yo0oni committed Jan 16, 2024
1 parent 27c267b commit 51a5d1c
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,38 @@ defaults:
working-directory: ./backend

env:
S3_BUCKET_NAME: howabouttrip-cicd-bucket
CODE_DEPLOY_APPLICATION_NAME: HowAboutTrip-Backend-CICD
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: HowAboutTrip-Backend-Instance
AWS_S3_BUCKET: howabouttrip-backend-bucket
AWS_CODE_DEPLOY_APPLICATION: HowAboutTrip-Backend-CD
AWS_CODE_DEPLOY_GROUP: HowAboutTrip-Backend-CD-Group

jobs:
deploy:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 17
java-version: '17'
distribution: 'corretto'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash

- name: Build and Test
- name: Build Project and Test
run: ./gradlew build test

- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash

- name: Configure AWS credentials
- name: Configure AWS credential
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ap-northeast-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip

- name: Code Deploy
run: |
aws deploy create-deployment \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip
run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://$AWS_S3_BUCKET/HowAboutTrip-Backend-EC2/$GITHUB_SHA.zip --source .

- name: Code Deploy to 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=HowAboutTrip-Backend-EC2/$GITHUB_SHA.zip,bundleType=zip

0 comments on commit 51a5d1c

Please sign in to comment.