From e460aabf9f4274c1a4b2e4540f010b3bcc39c4c8 Mon Sep 17 00:00:00 2001 From: 111coding Date: Thu, 30 Nov 2023 20:38:13 +0900 Subject: [PATCH] add workflow --- .ebextensions/00-makeFiles.config | 11 +++++ .github/workflows/deploy.yml | 53 +++++++++++++++++++++++ Procfile | 1 + src/main/resources/application-dev.yml | 2 +- src/main/resources/application-docker.yml | 2 +- src/main/resources/application-prod.yml | 2 +- 6 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 .ebextensions/00-makeFiles.config create mode 100644 .github/workflows/deploy.yml create mode 100644 Procfile diff --git a/.ebextensions/00-makeFiles.config b/.ebextensions/00-makeFiles.config new file mode 100644 index 0000000..e4654d5 --- /dev/null +++ b/.ebextensions/00-makeFiles.config @@ -0,0 +1,11 @@ +files: + "/sbin/appstart": + mode: "000755" + owner: webapp + group: webapp + content: | + #!/usr/bin/env bash + JAR_PATH=/var/app/current/application.jar + + # run app + java -Dspring.profiles.active=prod -Dfile.encoding=UTF-8 -jar $JAR_PATH \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..575f12c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,53 @@ +name: blog cicd +on: + push: + branches: + - main + +# https://github.com/actions/setup-java +# actions/setup-java@v2는 사용자 정의 배포를 지원하고 Zulu OpenJDK, Eclipse Temurin 및 Adopt OpenJDK를 기본적으로 지원합니다. v1은 Zulu OpenJDK만 지원합니다. +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: zulu + - name: Pemission + run: chmod +x ./gradlew + - name: Build with Gradle + run: ./gradlew clean build + + # UTC가 기준이기 때문에 한국시간으로 맞추려면 +9시간 해야 한다 + - name: Get current time + uses: 1466587594/get-current-time@v2 + id: current-time + with: + format: YYYY-MM-DDTHH-mm-ss + utcOffset: "+09:00" + + - name: Show Current Time + run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" + + # EB에 CD 하기 위해 추가 작성 + - name: Generate deployment package + run: | + mkdir deploy + cp build/libs/*.jar deploy/application.jar + cp Procfile deploy/Procfile + cp -r .ebextensions deploy/.ebextensions + cd deploy && zip -r deploy.zip . + - name: Deploy to EB + uses: einaregilsson/beanstalk-deploy@v21 + with: + aws_access_key: ${{ secrets.AWS_ACCESS_KEY }} + aws_secret_key: ${{ secrets.AWS_SECRET_KEY }} + application_name: blog-eb-test # 엘리스틱 빈스톡 애플리케이션 이름! + environment_name: Blog-eb-test-env # 엘리스틱 빈스톡 환경 이름! + version_label: blog-${{steps.current-time.outputs.formattedTime}} + region: ap-northeast-2 + deployment_package: deploy/deploy.zip \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..ffe0758 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +springapp: appstart \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index f47ab39..c073dc4 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,7 +4,7 @@ server: encoding: charset: utf-8 force: true - port: 8080 + port: 5000 spring: # 2 diff --git a/src/main/resources/application-docker.yml b/src/main/resources/application-docker.yml index dd83ae7..99cd42b 100644 --- a/src/main/resources/application-docker.yml +++ b/src/main/resources/application-docker.yml @@ -3,7 +3,7 @@ server: encoding: charset: utf-8 force: true - port: 8080 + port: 5000 spring: mustache: diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index c843bde..7c2b59f 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -3,7 +3,7 @@ server: encoding: charset: utf-8 force: true - port: 8080 + port: 5000 spring: mustache: