Skip to content

Merge pull request #175 from CoolPeace-yanolza/develop #36

Merge pull request #175 from CoolPeace-yanolza/develop

Merge pull request #175 from CoolPeace-yanolza/develop #36

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: CD
on:
push:
branches: [ "release" ]
env:
S3_BUCKET_NAME: coolpeace-s3
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 레포 체크아웃
uses: actions/checkout@v3
- name: Redis 셋업
uses: supercharge/[email protected]
with:
redis-version: 7.2
- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: .env.example 파일을 .env로 복사
run: cp .env.example .env
shell: bash
- name: gradlew에 실행권한 부여
run: chmod +x ./gradlew
shell: bash
- name: Gradle 빌드 및 테스트 실행
run: ./gradlew build -Pprod
shell: bash
- name: Gradle bootJar 패키징
run: ./gradlew bootJar
shell: bash
- name: .env 파일 제거
run: rm .env
shell: bash
- name: zip file 생성
run: zip -r ./$GITHUB_SHA.zip .
shell: bash
- name: AWS credentials 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY }}
aws-region: ap-northeast-2
- name: S3에 서버파일 업로드
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip
- name: Deploy
run: |
aws deploy create-deployment \
--region ap-northeast-2 \
--application-name coolpeace-codedeploy \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name coolpeace-deploy-group \
--file-exists-behavior OVERWRITE \
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip