Skip to content

refactor: README.md μˆ˜μ • #142

refactor: README.md μˆ˜μ •

refactor: README.md μˆ˜μ • #142

Workflow file for this run

name: Backend Workflows
on:
push:
branches:
- main # main으둜 pushν•˜λ©΄ workflow μ‹€ν–‰
paths:
- 'SCM/backend/**'
pull_request:
types: [ opened, reopened, synchronize ] # Pull Requestκ°€ μ—΄λ¦¬κ±°λ‚˜, λ‹€μ‹œ μ—΄λ¦¬κ±°λ‚˜, 동기화될 λ•Œ νŠΈλ¦¬κ±°λ©λ‹ˆλ‹€.
branches:
- main # main으둜 prν•˜λ©΄ workflow μ‹€ν–‰
jobs:
CI:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest # μ΅œμ‹  Ubuntu ν™˜κ²½
permissions:
contents: read # contents read κΆŒν•œμ„ λΆ€μ—¬
steps:
- uses: actions/checkout@v4 # λ ˆν¬μ§€ν† λ¦¬ μ½”λ“œλ₯Ό 체크아웃 [v4라고 버전 지정 μ‹œ v4둜 μ‹œμž‘ν•˜λŠ” μ΅œμ‹  릴리즈 버전을 μ‚¬μš© (μ •ν™•ν•œ 버전 κΈ°μž… μ‹œ ν•΄λ‹Ή 릴리즈 λ²„μ „λ§Œ μ‚¬μš©)]
# JDK 17 개발 ν™˜κ²½ μ„€μ •
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Gradle 버전 8.11 μ„€μ •
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.11"
# gradlew μ‹€ν–‰ κΆŒν•œ λΆ€μ—¬
- name: Grant execute permission for Gradle Wrapper
run: chmod +x ./gradlew
working-directory: ./SCM/backend
# envsubst 도ꡬ μ„€μΉ˜
- name: Install envsubst
# gettext νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•˜μ—¬ envsubst λͺ…령을 μ‚¬μš© κ°€λŠ₯ν•˜κ²Œ ν•©λ‹ˆλ‹€.
run: sudo apt-get install -y gettext
# application.yml ν…œν”Œλ¦Ώ 생성
- name: Create application.yml.template
run: |
mkdir -p SCM/backend/src/main/resources
cat > SCM/backend/src/main/resources/application.yml.template <<EOL
server:
port: 5000
servlet:
encoding:
charset: UTF-8
spring:
application:
name: orderBridge
datasource:
url: jdbc:log4jdbc:mariadb://\${RDS_HOSTNAME}:\${RDS_PORT}/\${RDS_DB_NAME}?serverTimezone=Asia/Seoul
username: \${RDS_USERNAME}
password: \${RDS_PASSWORD}
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
hikari:
idle-timeout: 300000
max-lifetime: 1800000
pool-name: HikariPool-1
jpa:
show-sql: true
hibernate:
ddl-auto: none
naming:
physical-strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
properties:
hibernate:
format_sql: true
hibernate.dialect: org.hibernate.dialect.MariaDBDialect
data:
redis:
host: \${REDIS_HOST}
port: \${REDIS_PORT}
username: \${REDIS_HOSTNAME}
password: \${REDIS_PASSWORD}
springdoc:
packages-to-scan: error.pirate.backend
default-consumes-media-type: application/json;charset=UTF-8
default-produces-media-type: application/json;charset=UTF-8
swagger-ui:
path: /swagger
operations-sorter: method
doc-expansion: none
logging:
file:
path: /var/app/current
level:
root: info
org.springframework.web: info
com.zaxxer.hikari: debug
log4jdbc.log4j2: error
jdbc.sqlonly: info
jdbc.resultsettable: info
jdbc.connection: info
mybatis:
configuration:
map-underscore-to-camel-case: true
mapper-locations: mappers/**/*.xml
jwt:
secretKey: \${JWT_SECRET_KEY}
access:
expiration: 3600000 # 1μ‹œκ°„
header: Authorization
refresh:
expiration: 1209600000 # 2μ£Ό
header: Refresh-Token
frontend: \${FRONTEND_URL}
gemini:
baseurl: \${GEMINI_URL}
googleai:
api:
key: \${GEMINI_KEY}
cloud:
aws:
s3:
bucket: \${AWS_S3_BUCKET}
credentials:
access-key: \${AWS_ACCESS_KEY_ID}
secret-key: \${AWS_SECRET_ACCESS_KEY}
region:
static: \${AWS_REGION}
auto: false
stack:
auto: false
EOL
# ν…œν”Œλ¦Ώ νŒŒμΌμ— ν™˜κ²½ λ³€μˆ˜λ₯Ό λŒ€μž…ν•˜μ—¬ application.yml 생성
- name: Set Yaml
run: |
envsubst < SCM/backend/src/main/resources/application.yml.template > SCM/backend/src/main/resources/application.yml
echo "Generated application.yml:"
cat SCM/backend/src/main/resources/application.yml
env:
RDS_HOSTNAME: ${{ secrets.RDS_HOSTNAME }}
RDS_PORT: ${{ secrets.RDS_PORT }}
RDS_DB_NAME: ${{ secrets.RDS_DB_NAME }}
RDS_USERNAME: ${{ secrets.RDS_USERNAME }}
RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_HOSTNAME: ${{ secrets.REDIS_HOSTNAME }}
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
GEMINI_URL: ${{ secrets.GEMINI_URL }}
GEMINI_KEY: ${{ secrets.GEMINI_KEY }}
FRONTEND_URL: ${{ secrets.FRONTEND_URL }}
AWS_S3_BUCKET: ${{ secrets.S3_BUCKET_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
# backend λΉŒλ“œ
- name: Build with Gradle Wrapper
run: ./gradlew build -x test # ν…ŒμŠ€νŠΈ μ½”λ“œ μ œμ™Έ λΉŒλ“œ
working-directory: ./SCM/backend
# backend Test Code μ‹€ν–‰
#- name: Run Test
# run: ./gradlew test
# working-directory: ./SCM/backend
# continue-on-error: true
# Test κ²°κ³Ό νŒŒμΌμ„ μ•„μΉ΄μ΄λΈŒλ‘œ μ €μž₯ν•˜μ—¬ Github Actionsμ—μ„œ 확인할 수 μžˆλ„λ‘ ν•œλ‹€.
#- name: Archive Test Results
# if: always() # 이 μ „ λ‹¨κ³„μ˜ 성곡 여뢀와 관계없이 항상 μ‹€ν–‰
# uses: actions/upload-artifact@v3
# with:
# name: test-results
# path: |
# ./SCM/backend/build/test-results/test
# ./SCM/backend/build/reports/tests/test
CD:
if: github.event_name == 'push'
runs-on: ubuntu-latest # μ΅œμ‹  Ubuntu ν™˜κ²½
permissions:
contents: read # contents read κΆŒν•œμ„ λΆ€μ—¬
steps:
- uses: actions/checkout@v4 # λ ˆν¬μ§€ν† λ¦¬ μ½”λ“œλ₯Ό 체크아웃 [v4라고 버전 지정 μ‹œ v4둜 μ‹œμž‘ν•˜λŠ” μ΅œμ‹  릴리즈 버전을 μ‚¬μš© (μ •ν™•ν•œ 버전 κΈ°μž… μ‹œ ν•΄λ‹Ή 릴리즈 λ²„μ „λ§Œ μ‚¬μš©)]
# JDK 17 개발 ν™˜κ²½ μ„€μ •
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Gradle 버전 8.11 μ„€μ •
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.11"
# gradlew μ‹€ν–‰ κΆŒν•œ λΆ€μ—¬
- name: Grant execute permission for Gradle Wrapper
run: chmod +x ./gradlew
working-directory: ./SCM/backend
# envsubst 도ꡬ μ„€μΉ˜
- name: Install envsubst
# gettext νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•˜μ—¬ envsubst λͺ…령을 μ‚¬μš© κ°€λŠ₯ν•˜κ²Œ ν•©λ‹ˆλ‹€.
run: sudo apt-get install -y gettext
# application.yml ν…œν”Œλ¦Ώ 생성
- name: Create application.yml.template
run: |
mkdir -p SCM/backend/src/main/resources
cat > SCM/backend/src/main/resources/application.yml.template <<EOL
server:
port: 5000
servlet:
encoding:
charset: UTF-8
spring:
application:
name: orderBridge
datasource:
url: jdbc:log4jdbc:mariadb://\${RDS_HOSTNAME}:\${RDS_PORT}/\${RDS_DB_NAME}?serverTimezone=Asia/Seoul
username: \${RDS_USERNAME}
password: \${RDS_PASSWORD}
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
hikari:
idle-timeout: 300000
max-lifetime: 1800000
pool-name: HikariPool-1
jpa:
show-sql: true
hibernate:
ddl-auto: none
naming:
physical-strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
properties:
hibernate:
format_sql: true
hibernate.dialect: org.hibernate.dialect.MariaDBDialect
data:
redis:
host: \${REDIS_HOST}
port: \${REDIS_PORT}
username: \${REDIS_HOSTNAME}
password: \${REDIS_PASSWORD}
springdoc:
packages-to-scan: error.pirate.backend
default-consumes-media-type: application/json;charset=UTF-8
default-produces-media-type: application/json;charset=UTF-8
swagger-ui:
path: /swagger
operations-sorter: method
doc-expansion: none
logging:
file:
path: /var/app/current
level:
root: info
org.springframework.web: info
com.zaxxer.hikari: debug
log4jdbc.log4j2: error
jdbc.sqlonly: info
jdbc.resultsettable: info
jdbc.connection: info
mybatis:
configuration:
map-underscore-to-camel-case: true
mapper-locations: mappers/**/*.xml
jwt:
secretKey: \${JWT_SECRET_KEY}
access:
expiration: 3600000 # 1μ‹œκ°„
header: Authorization
refresh:
expiration: 1209600000 # 2μ£Ό
header: Refresh-Token
frontend: \${FRONTEND_URL}
gemini:
baseurl: \${GEMINI_URL}
googleai:
api:
key: \${GEMINI_KEY}
cloud:
aws:
s3:
bucket: \${AWS_S3_BUCKET}
credentials:
access-key: \${AWS_ACCESS_KEY_ID}
secret-key: \${AWS_SECRET_ACCESS_KEY}
region:
static: \${AWS_REGION}
auto: false
stack:
auto: false
EOL
# ν…œν”Œλ¦Ώ νŒŒμΌμ— ν™˜κ²½ λ³€μˆ˜λ₯Ό λŒ€μž…ν•˜μ—¬ application.yml 생성
- name: Set Yaml
run: |
envsubst < SCM/backend/src/main/resources/application.yml.template > SCM/backend/src/main/resources/application.yml
echo "Generated application.yml:"
cat SCM/backend/src/main/resources/application.yml
env:
RDS_HOSTNAME: ${{ secrets.RDS_HOSTNAME }}
RDS_PORT: ${{ secrets.RDS_PORT }}
RDS_DB_NAME: ${{ secrets.RDS_DB_NAME }}
RDS_USERNAME: ${{ secrets.RDS_USERNAME }}
RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_HOSTNAME: ${{ secrets.REDIS_HOSTNAME }}
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
GEMINI_URL: ${{ secrets.GEMINI_URL }}
GEMINI_KEY: ${{ secrets.GEMINI_KEY }}
FRONTEND_URL: ${{ secrets.FRONTEND_URL }}
AWS_S3_BUCKET: ${{ secrets.S3_BUCKET_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
# backend λΉŒλ“œ
- name: Build with Gradle Wrapper
run: ./gradlew build -x test # ν…ŒμŠ€νŠΈ μ½”λ“œ μ œμ™Έ λΉŒλ“œ
working-directory: ./SCM/backend
# backend Test Code μ‹€ν–‰
#- name: Run Test
# run: ./gradlew test
# working-directory: ./SCM/backend
# continue-on-error: true
# Test κ²°κ³Ό νŒŒμΌμ„ μ•„μΉ΄μ΄λΈŒλ‘œ μ €μž₯ν•˜μ—¬ Github Actionsμ—μ„œ 확인할 수 μžˆλ„λ‘ ν•œλ‹€.
#- name: Archive Test Results
# if: always() # 이 μ „ λ‹¨κ³„μ˜ 성곡 여뢀와 관계없이 항상 μ‹€ν–‰
# uses: actions/upload-artifact@v3
# with:
# name: test-results
# path: |
# ./SCM/backend/build/test-results/test
# ./SCM/backend/build/reports/tests/test
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DD HH:mm:ss
utcOffset: "+09:00"
- name: Show Current Time
run: echo "currentTime=${{steps.current-time.outputs.formattedTime}}"
shell: bash
- name: Generate backend deployment package
run: |
mkdir -p deploy
cp SCM/backend/build/libs/*.jar deploy/application.jar
cp Procfile_back deploy/Procfile
cp -r SCM/backend/.ebextensions deploy/.ebextensions
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
- name: Beanstalk backend Deploy
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: ${{ secrets.AWS_ELASTIC_BEANSTALK_BACKEND_APPLICATION }}
environment_name: ${{ secrets.AWS_ELASTIC_BEANSTALK_BACKEND_ENV }}
version_label: github-action-backend_${{steps.current-time.outputs.formattedTime}}
region: ${{ secrets.AWS_REGION }}
deployment_package: deploy/deploy.zip
use_existing_version_if_available: false
wait_for_deployment: true
wait_for_environment_recovery: 300
# ν”„λ‘œμ νŠΈμ˜ μ˜μ‘΄μ„± κ·Έλž˜ν”„λ₯Ό 생성 및 μ œμΆœν•˜μ—¬ Githubμ—μ„œ μ‹œκ°μ μœΌλ‘œ κ΄€λ¦¬ν•˜λ„λ‘ ν•œλ‹€.
dependency-submission:
runs-on: ubuntu-latest
# μ“°κΈ° κΆŒν•œμ„ μ£Όμ–΄ μ˜μ‘΄μ„± 데이터λ₯Ό Github에 μ œμΆœν•  수 μžˆλ‹€.
permissions:
contents: write
steps:
# μ½”λ“œ 체크아웃
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Generate and submit dependency graph
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.11"