Skip to content
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
44 changes: 0 additions & 44 deletions .github/workflows/ci.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI/CD - Build, Test, and Deploy

on:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev
workflow_dispatch:

permissions:
id-token: write
contents: read

env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: first-ticket/config-server

jobs:
# 1) 빌드 + 테스트 (모든 PR/push에서 실행)
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6

- name: Grant execute permission to gradlew
run: chmod +x gradlew

- name: Build & Test
run: ./gradlew build --no-daemon

- name: Upload test report (on failure)
if: failure()
uses: actions/upload-artifact@v5
with:
name: test-report
path: build/reports/tests/
retention-days: 7

# 2) ECR 푸시 (main 브랜치 push 시)
push-to-ecr:
needs: build-and-test
if: |
github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew clean build -x test

- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: ecr-login
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push image to ECR
env:
REGISTRY: ${{ steps.ecr-login.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build --platform linux/amd64 \
-t $REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-t $REGISTRY/$ECR_REPOSITORY:latest .
docker push $REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/$ECR_REPOSITORY:latest

- name: Show pushed image
run: |
echo "✅ Pushed: $ECR_REPOSITORY:${{ github.sha }}"
echo "✅ Pushed: $ECR_REPOSITORY:latest"
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@ ext {
}

dependencies {
// Spring Boot
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'

// Spring Cloud
implementation 'org.springframework.cloud:spring-cloud-config-server'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'

// 모니터링
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'

// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testCompileOnly 'org.projectlombok:lombok'
Expand Down
12 changes: 11 additions & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
server:
port: 8080

spring:
cloud:
inetutils:
preferred-networks:
- 10\.
- 172\.
Comment thread
rlaxxwls13 marked this conversation as resolved.
- 192\.168\.

eureka:
client:
enabled: true
service-url:
defaultZone: ${EUREKA_URL:http://eureka-server:8761/eureka/}
instance:
prefer-ip-address: true

logging:
level:
org.springframework.cloud.config: INFO
org.springframework.cloud.config: INFO
9 changes: 9 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ spring:
search-paths:
- '{application}'

management:
endpoints:
web:
exposure:
include: prometheus, health, info
endpoint:
prometheus:
access: read-only

logging:
level:
org.springframework.cloud.config: INFO
Expand Down