Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: CD workflow #42

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .ebextensions/healthcheck.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
option_settings:
aws:elasticbeanstalk:application:
Application Healthcheck URL: "/health"
56 changes: 56 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CD
on:
push:
branches:
- release/**

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: μ†ŒμŠ€ μ½”λ“œ λ‹€μš΄λ‘œλ“œ
uses: actions/checkout@v3

- name: JDK λ‹€μš΄λ‘œλ“œ
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 21

- name: λΉŒλ“œ 캐싱
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: ν˜„μž¬ μ‹œκ°„ κ°€μ Έμ˜€κΈ°
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"

- name: λΉŒλ“œ
run: chmod +x gradlew && ./gradlew bootJar

- name: 배포 μ••μΆ• 파일 생성
run: |
sed -i 's/{JASYPT_SECRET}/${{ secrets.JASYPT_ENCRYPTOR_PASSWORD }}/' ./deploy/Procfile
cp ./api/build/libs/api-1.0.0.jar ./deploy/application.jar
cd deploy && zip -r deploy.zip .

- name: 배포
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
application_name: dojo-backend-eb-app
environment_name: dojo-backend-eb-env
version_label: dojo-${{ vars.GITHUB_SHA }}-${{steps.current-time.outputs.formattedTime}}
region: ap-northeast-2
deployment_package: ./deploy/deploy.zip
wait_for_deployment: true
14 changes: 14 additions & 0 deletions api/src/main/kotlin/com/mashup/dojo/HealthController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.mashup.dojo

import io.swagger.v3.oas.annotations.Hidden
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class HealthController {
@Hidden
@GetMapping("/health")
fun health(): String {
return "OK"
}
}
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ subprojects {
}

tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootJar> {
mainClass.set("com.mashup.dojo.DojoApplication") // 메인 클래슀λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€
mainClass.set("com.mashup.dojo.DojoApplicationKt") // 메인 클래슀λ₯Ό μ„€μ •ν•©λ‹ˆλ‹€
}
}

springBoot {
mainClass.set("com.mashup.dojo.DojoApplication")
mainClass.set("com.mashup.dojo.DojoApplicationKt")
}

project(":api") {
Expand Down
1 change: 1 addition & 0 deletions deploy/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: java -jar -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -Dserver.port=5000 -DJASYPT_ENCRYPTOR_PASSWORD={JASYPT_SECRET} ./application.jar
Loading