Merge pull request #200 from TravelLaboratory/dev #80
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: Deploy to Production | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
# todo - docker 만들어서 rds에 연동하기 (test db) | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
# - name: Gradle Caching | |
# uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ~/.gradle/caches | |
# ~/.gradle/wrapper | |
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
# restore-keys: | | |
# ${{ runner.os }}-gradle- | |
# todo 임시 github secrets -> 배포하기 위한 application.yml 환경변수 설정 | |
- name: Set application-prod.yml | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ./src/main/resources/application-prod.yml | |
env: | |
server.port: ${{ secrets.SERVER_PORT }} | |
management.server.port: ${{ secrets.MANAGEMENT_SERVER_PORT }} | |
spring.datasource.url: ${{ secrets.DB_URL }} | |
spring.datasource.username: ${{ secrets.DB_USERNAME }} | |
spring.datasource.password: ${{ secrets.DB_PASSWORD }} | |
spring.data.redis.host: ${{ secrets.REDIS_HOST }} | |
spring.data.redis.port: ${{ secrets.REDIS_PORT }} | |
jwt.secret-key: ${{ secrets.JWT_SECRET_KEY }} | |
jwt.access-token.plus-hour: ${{ secrets.JWT_ACCESS_TOKEN_PLUS_HOUR }} | |
jwt.refresh-token.plus-hour: ${{ secrets.JWT_REFRESH_TOKEN_PLUS_HOUR }} | |
servers.url: ${{ secrets.SERVERS_URL }} | |
cloud.aws.s3.bucket: ${{ secrets.CLOUD_AWS_S3_BUCKET }} | |
cloud.aws.credentials.access-key: ${{ secrets.CLOUD_AWS_CREDENTIALS_ACCESS_KEY }} | |
cloud.aws.credentials.secret-key: ${{ secrets.CLOUD_AWS_CREDENTIALS_SECRET_KEY }} | |
cloud.aws.region.static: ${{ secrets.CLOUD_AWS_REGION_STATIC }} | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean build -x test | |
# 수정 | |
- name: Make zip file | |
run: | | |
mkdir deploy | |
cp ./appspec.yml ./deploy/ | |
cp ./Dockerfile ./deploy/ | |
cp ./scripts/deploy.sh ./deploy/ | |
cp ./build/libs/*.jar ./deploy/ | |
zip -r -qq -j ./${{ secrets.AWS_S3_BUILD }} ./deploy | |
- 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 ${{ secrets.AWS_REGION }} \ | |
./${{ secrets.AWS_S3_BUILD }} s3://${{ secrets.AWS_S3_BUCKET_NAME }} | |
# 추가 | |
- name: Code Deploy | |
run: aws deploy create-deployment --application-name ${{ secrets.CODE_DEPLOY_APPLICATION_NAME }} | |
--deployment-config-name CodeDeployDefault.OneAtATime | |
--deployment-group-name ${{ secrets.DEPLOYMENT_GROUP_NAME }} | |
--s3-location bucket=${{ secrets.AWS_S3_BUCKET_NAME }},bundleType=zip,key=${{ secrets.AWS_S3_BUILD }} |