Merge pull request #43 from 2023-Team-Luna-Achieve/BE/Feat/#32 #29
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
on: | |
push: | |
branches: ["feature"] | |
name: Deploy achieve project to Amazon EC2 | |
env: | |
PROJECT_NAME: achieve | |
BUCKET_NAME: ec2-s3-deploy-bucket | |
APPLICATION_NAME: achieve-deploy-app | |
DEPLOYMENT_GROUP_NAME: achieve-deploy-group | |
jobs: | |
deploy: | |
name: DEPLOY | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
- name: Make application.yml | |
run: echo "${{ secrets.APPLICATION_PROD }}" > ./backend/src/main/resources/application-prod.yml | |
- name: Make aws RDS env file | |
run: echo "${{ secrets.AWS_RDS }}" > ./.env | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./backend/gradlew | |
shell: bash | |
- name: Build with Gradle | |
run: | | |
cd backend | |
./gradlew clean bootJar --exclude-task test | |
shell: bash | |
- name: Make zip file | |
run: zip -qq -r ./$GITHUB_SHA.zip . | |
shell: bash | |
- 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 }} | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip | |
- name: Code Deploy | |
run: aws deploy create-deployment --application-name $APPLICATION_NAME --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip --ignore-application-stop-failures |