Merge pull request #55 from dnd-side-project/feature/#45 #50
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: [ "develop" ] | |
permissions: write-all | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
## JDK 버전 : 17 | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
## 빌드 시간 단축용 gradle 캐싱 | |
- 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- | |
## yml 파일 생성 | |
- name: Set up yml file | |
env: | |
YAML_SECRET: ${{ secrets.APPLICATION_DEV_YML }} | |
YAML_DIR: src/main/resources | |
YAML_FILE_NAME: application-dev.yml | |
run: echo $YAML_SECRET | base64 --decode > $YAML_DIR/$YAML_FILE_NAME | |
## gradlew 권한 부여 및 빌드 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Make zip file | |
run: | | |
mkdir deploy | |
cp ./docker-compose.blue.yml ./deploy/ | |
cp ./docker-compose.green.yml ./deploy/ | |
cp ./appspec.yml ./deploy/ | |
cp ./Dockerfile ./deploy/ | |
cp ./scripts/*.sh ./deploy/ | |
cp ./build/libs/*.jar ./deploy/ | |
zip -r -qq -j ./chillin-build.zip ./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: ap-northeast-2 | |
- name: Upload to S3 | |
run: | | |
aws s3 cp \ | |
--region ap-northeast-2 \ | |
./chillin-build.zip s3://chillin-bucket | |
- name: Code Deploy | |
run: aws deploy create-deployment --application-name chillin-codedeploy | |
--deployment-config-name CodeDeployDefault.OneAtATime | |
--deployment-group-name chillin-deploy-group | |
--s3-location bucket=chillin-bucket,bundleType=zip,key=chillin-build.zip |