Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
46de305
🏗️ setup: 프로젝트 초기 설정(close #1)
hyeminleeee Aug 9, 2025
106aa6d
Merge pull request #3 from next-engineer/feature/1-init-project
Mminzy22 Aug 9, 2025
5442a1c
🔧 config: gradle wrapper 복구 및 .gitignore 예외 처리
Mminzy22 Aug 9, 2025
e2c690d
📦 chore: build.gradle 편의 의존성 추가
Mminzy22 Aug 9, 2025
dcf9cf3
🔧 config: pre-commit 및 commit-msg 훅 설정
Mminzy22 Aug 9, 2025
37cb617
🏗️ setup: 개발 환경 초기 설정 스크립트 추가
Mminzy22 Aug 9, 2025
bb1dfdc
🔧 config: .gitignore `!` 예외 처리 하단으로 위치 변경
Mminzy22 Aug 9, 2025
7260bb6
Merge pull request #5 from next-engineer/feature/4-setup-precommit-co…
hyeminleeee Aug 9, 2025
12419d0
🔧 config: dev, prod 환경별 Spring 설정 파일 분리 적용
hyeminleeee Aug 9, 2025
75da0a2
Merge pull request #8 from next-engineer/feature/2-add-env-config
Mminzy22 Aug 9, 2025
456bd2d
✨ feat(user): user 엔터티 및 repository 추가
hyeminleeee Aug 10, 2025
11488bd
🎨 style: apply formatter (no logic change)
hyeminleeee Aug 10, 2025
b88cedc
✏️ fix: rankenum 오타 수정
hyeminleeee Aug 10, 2025
cc7d748
♻️ refactor: user entitiy refactoring(no logic change)
hyeminleeee Aug 10, 2025
50c0e05
♻️ refactor(structure): 디렉토리 변경
hyeminleeee Aug 10, 2025
24b4030
Merge pull request #10 from next-engineer/feature/3-create-users-table
Mminzy22 Aug 10, 2025
5dd18b8
✨feat(config): SecurityConfig (cors bridge, /api/**, swagger) 추가
imjwoo Aug 11, 2025
b7aac1c
✨feat(config): WebConfig CORS 추가
imjwoo Aug 11, 2025
136c5f3
🔧 config: Swagger 사용 및 Security 설정을 위한 의존성 추가
imjwoo Aug 11, 2025
0f7611c
"🔧 config: SecurityConfig, WebConfig @Configuration 추가
imjwoo Aug 11, 2025
961c8b1
✨feat(config):SwaggerConfig 추가
imjwoo Aug 11, 2025
e803a55
🔧 config: 환경별 CORS 허용 Origin 설정을 yml에서 관리하도록 변경
imjwoo Aug 11, 2025
a6dfd65
🎨style: 사용되지 않는 import 제거
imjwoo Aug 11, 2025
4291753
Merge pull request #15 from next-engineer/feature/14-config-base
Mminzy22 Aug 11, 2025
6abf3fe
✨ feat(match): match entity, repository 추가
deepInTheWoodz Aug 11, 2025
c94c363
Merge branch 'develop' of https://github.com/next-engineer/next-kicky…
hyeminleeee Aug 12, 2025
a927345
✨ feat(match): match entity, repository 추가
deepInTheWoodz Aug 12, 2025
6e149c7
♻️ refactor(user): 사용자 기본 프로필 사진 URL 설정 및 엔티티 정리
hyeminleeee Aug 12, 2025
b188355
Merge pull request #20 from next-engineer/feature/16-user-entity-modify
Mminzy22 Aug 12, 2025
5d465bf
🔧 config(cins CI 설정
taeyeon119 Aug 12, 2025
65333fc
✨ feat(match): match entity 어노테이션 추가
deepInTheWoodz Aug 12, 2025
9e95a14
Merge pull request #19 from next-engineer/feature/12-match-entity-repo
Mminzy22 Aug 12, 2025
5577fbd
🔧 config(ci): GitHu¤정 추가 (build, lint 포함)
taeyeon119 Aug 12, 2025
b4b7d74
🔧 config(husky): pre-commit 파일 인코딩 문제 수정
Mminzy22 Aug 12, 2025
9737e13
🎨 style: 기존 로직에는 영향 없이 코드 포맷만 수정
Mminzy22 Aug 12, 2025
d3f7853
Merge pull request #23 from next-engineer/feature/spotless-format-fix
hyeminleeee Aug 12, 2025
ef53ee2
Merge branch 'develop' of https://github.com/next-engineer/next-kicky…
taeyeon119 Aug 12, 2025
4443765
Merge pull request #22 from next-engineer/feature/18-ci
Mminzy22 Aug 12, 2025
00dcc8a
🔧 config(script): pip install 후 환경 즉시 반영하도록 쉘 스크립트 수정
Mminzy22 Aug 12, 2025
1b37865
Merge pull request #24 from next-engineer/feature/update-script-env-r…
imjwoo Aug 12, 2025
eccb851
📦 chore: husky 전용 setup 스크립트로 변경
Mminzy22 Aug 12, 2025
a0cab85
Merge pull request #25 from next-engineer/feature/setup-husky-only
hyeminleeee Aug 12, 2025
300ffee
📦 chore: oauth2 리소스 서버 라이브러리 추가
hyeminleeee Aug 12, 2025
e38bf31
📦 chore: jwt 검증 설정(application.yml)
hyeminleeee Aug 12, 2025
2f34eb0
✨ feat(user): jwt 자동 검증 설정 추가
hyeminleeee Aug 12, 2025
3724301
🎨 style: securityConfig 파일 줄 정리
hyeminleeee Aug 12, 2025
0c7d1d7
✨ feat(user): userRepository findByCognitoSub으로 변경
hyeminleeee Aug 12, 2025
0da5231
✨ feat(user): userService 생성
hyeminleeee Aug 12, 2025
8a1dcb6
🎨 style: userService 공백 정리
hyeminleeee Aug 12, 2025
91d3750
✨ feat(user): userController 추가
hyeminleeee Aug 12, 2025
6f49ffb
✨ feat(user): user Entity 어노테이션 수정
hyeminleeee Aug 12, 2025
4422eb3
✏️ fix: 오타수정
hyeminleeee Aug 12, 2025
dcc7494
✨ feat(user): 프로필 기본 사진 추가
hyeminleeee Aug 12, 2025
b57b419
Merge pull request #28 from next-engineer/feature/19-back-cognito-con…
Mminzy22 Aug 12, 2025
7c80927
✨ feat(match): MatchParticipant 엔티티 생성
imjwoo Aug 12, 2025
69ef7f4
✨ feat(match): MatchParticipant 레포지토리 생성
imjwoo Aug 12, 2025
3b0bf59
✨ feat(common): created_at, updated_at base entity에 생성
imjwoo Aug 12, 2025
1ed342c
✨ feat(match): 중복된 UNIQUE 제약 조건 해결을 위해 name 명시
imjwoo Aug 12, 2025
01101cf
🎨 style: Spotless/Checkstyle 규칙 적용 및 import 순서·와일드카드 수정
imjwoo Aug 12, 2025
caf6744
Merge pull request #29 from next-engineer/feature/11-match-participan…
Mminzy22 Aug 12, 2025
a6bfbe3
✨ feat(user): application.yml cognito 사용자 풀 정보 입력(보안이슈x)
hyeminleeee Aug 13, 2025
a66873a
✨ feat(user): accessToken 디코더 추가
hyeminleeee Aug 13, 2025
cd5c273
✨ feat(user): 토큰 유효성 추가 검사
hyeminleeee Aug 13, 2025
1a5d068
✨ feat(match): 관리자 매치 삭제 API 구현
taeyeon119 Aug 13, 2025
2af5871
✨ feat(user): 사용자 정보 json으로 추출
hyeminleeee Aug 13, 2025
296a0a2
✨ feat(user): 회원가입 post로 변경
hyeminleeee Aug 13, 2025
9c391ce
✨ feat(match): 관리자 매치 삭제 API 구현
taeyeon119 Aug 13, 2025
dce3ef0
Merge pull request #33 from next-engineer/feature/27-user-sign-in-up
Mminzy22 Aug 13, 2025
deeccb9
✨ feat(match): 관리자 매치 삭제 API 구현
taeyeon119 Aug 13, 2025
9e02e15
✨ feat(match): 관리자 매치✨ feat(m 로직 추가
taeyeon119 Aug 13, 2025
78fad83
🎨 style: import 순서 및 공백 정리
taeyeon119 Aug 13, 2025
351e4b6
🐛 fix: import 순서 맞춤
taeyeon119 Aug 13, 2025
20f9ebe
♻️ 코드 포맷팅 적용 (spotless)
taeyeon119 Aug 13, 2025
070f972
✨ feat(user): 내 프로필 조회 api 구현(Controller, Service, DTO)
hyeminleeee Aug 13, 2025
ce97a4c
Merge pull request #35 from next-engineer/feature/30-my-profile
Mminzy22 Aug 13, 2025
e3a011f
✨ feat(match): 관리자 매칭 삭제 API 구현
taeyeon119 Aug 13, 2025
ea6a34e
🚨 fix(test): 테스트 실패 원인 수정
taeyeon119 Aug 13, 2025
b7dc6ac
✨ feat(match): match 경기 조회 구현
deepInTheWoodz Aug 13, 2025
361016a
🧪 test(match): match 경기 조회 서비스 테스트 구현
deepInTheWoodz Aug 13, 2025
c621a3a
✨ test(match): 누락된 MatchResponseDto 추가
deepInTheWoodz Aug 13, 2025
1af1c18
🚨 fix(match): 테스트 실패 원인 수정
deepInTheWoodz Aug 13, 2025
b86b125
Merge pull request #32 from next-engineer/feature/31-match-delete-api
Mminzy22 Aug 13, 2025
bf2fc13
🚨 fix(match): 테스트 실패 원인 수정
deepInTheWoodz Aug 13, 2025
de8df1f
Merge pull request #42 from next-engineer/feature/36-match
Mminzy22 Aug 13, 2025
7cd6ce1
🧪 test(user): 내 프로필 조회, 로그인, 회원가입 API 테스트 추가
hyeminleeee Aug 13, 2025
4c5a531
✨ feat(match): 관리자 경기 개설 api 추가
deepInTheWoodz Aug 13, 2025
516d929
🧪 test(match): 경기개설 테스트 추가
deepInTheWoodz Aug 13, 2025
c1852a7
Merge pull request #44 from next-engineer/feature/37-match
Mminzy22 Aug 13, 2025
36dcaa0
✨ feat(match): 경기 참여 api 추가
deepInTheWoodz Aug 13, 2025
e465892
🧪 test(match): 경기참여 테스트 코드 추가
deepInTheWoodz Aug 13, 2025
3fcc9d5
Merge pull request #45 from next-engineer/feature/38-match
Mminzy22 Aug 13, 2025
8f86acd
✨ feat(match): 경기 참여 취소 api 추가
deepInTheWoodz Aug 13, 2025
0289e71
🧪 test(match): 경기 참여 api 테스트 추가
deepInTheWoodz Aug 13, 2025
14d40c2
Merge pull request #46 from next-engineer/feature/39-match
Mminzy22 Aug 13, 2025
7f620e3
Merge pull request #47 from next-engineer/feature/43-my-profile-unit-…
Mminzy22 Aug 13, 2025
66b1676
✨ feat(user): userDto createdAt 추가
hyeminleeee Aug 13, 2025
6f55b9a
✨ feat(auth): 나의 매치 목록 확인 controller 추가
imjwoo Aug 13, 2025
ea0681a
✨ feat(match): jpql을 사용해서 나의 매칭 목록 조회 쿼리 작성
imjwoo Aug 13, 2025
f1e2f6a
✨ feat(match): 나의 매칭 목록 서비스 로직 추가
imjwoo Aug 13, 2025
a329a59
✨ feat(user): userDto createdAt 추가
hyeminleeee Aug 13, 2025
865a023
Merge pull request #49 from next-engineer/feature/48-createdat-dto-add
Mminzy22 Aug 14, 2025
b0cee06
♻️ refactor: 나의 매치 목록 서비스 로직 수정
Aug 14, 2025
b356008
♻️ refactor: 매치 관련 파일 위치 수정
Aug 14, 2025
707e192
♻️ refactor: 매치 관련 파일 위치 수정
Aug 14, 2025
44a3b18
🧪 test(match): 나의 매치 목록 조회 test 코드 작성
Aug 14, 2025
845306b
♻️ refactor: 관리자 삭제 병합 시 충돌 방지
Aug 14, 2025
d74fcfc
Merge pull request #52 from next-engineer/feature/40-match-me-api
Mminzy22 Aug 14, 2025
434106b
♻️ refactor: 매칭 삭제 기능 관련 컨트롤러 서비스 파일로 경로 변경
taeyeon119 Aug 14, 2025
02b729d
🎨 style: 코드 스타일 변경
taeyeon119 Aug 14, 2025
e0d02ba
🧪 test(user): 경기 삭제 api test 추가
taeyeon119 Aug 14, 2025
c8b3dc1
Merge pull request #54 from next-engineer/feature/41-match-delete-api…
Mminzy22 Aug 14, 2025
4268dd9
♻️ refactor: application.yml 역할 분할
Aug 14, 2025
728a38d
♻️ refactor: application.yml cognito 추가
Aug 14, 2025
072e624
✏️ fix: 환경 변수 추가
imjwoo Aug 15, 2025
11d8632
✏️ fix: 리소스 서버 자동 설정 비활성화 → jwk 원격 호출 방지
imjwoo Aug 15, 2025
88a7c69
✏️ fix: dev gitignore 처리 추가 설정
imjwoo Aug 15, 2025
8c1bfa7
✏️ fix: 검증 스탭에서 실패 허용
imjwoo Aug 15, 2025
ecf3cda
Merge pull request #55 from next-engineer/feature/update-application-yml
Mminzy22 Aug 15, 2025
f346b5f
✨ feat(user): email_verified 추가
hyeminleeee Aug 16, 2025
9985067
🧪 test(user): email_verified 추가로 인한 테스트 변경
hyeminleeee Aug 16, 2025
3d8e788
🎨 style: 공백 및 줄 정리
hyeminleeee Aug 16, 2025
b20031f
Merge pull request #57 from next-engineer/feature/51-email-verified-add
Mminzy22 Aug 16, 2025
0c8c85b
✨ feat(user): 의존성 추가
hyeminleeee Aug 16, 2025
cc1a2cd
✨ feat(user): cognito 사용자 풀 → RDS 사용자 백필 기능 추가
hyeminleeee Aug 16, 2025
11d99c3
✨ feat: build.gradle group 수정
hyeminleeee Aug 16, 2025
a166000
Merge pull request #59 from next-engineer/feature/57-cognito-backfill
Mminzy22 Aug 16, 2025
618745f
🏗️ setup: 이미지 빌드를 위한 docker file 추가
imjwoo Aug 16, 2025
c80d477
Merge pull request #60 from next-engineer/feature/add-docker-file
Mminzy22 Aug 16, 2025
9dc7772
🐛 fix(match): front와 api연결하며 데이터 전송방식, 변수명 등 통일되지 않은 부분 수정
deepInTheWoodz Aug 16, 2025
840d3af
🐛 fix(match): 이전 커밋할 때 precommit이 안돼서 precommit 후 재 커밋
deepInTheWoodz Aug 16, 2025
86db817
🏗️ setup: ecr 레포지토리 도커 이미지 빌드 후 배포
imjwoo Aug 16, 2025
87997a7
🏗️ setup: 태스크 정의 생성 후 서비스에 태스크 적용 ecs 배포
imjwoo Aug 16, 2025
f4ef871
🏗️ setup: main 브랜치 작업전 develop 브랜치 테스트
imjwoo Aug 16, 2025
f1eea6c
Merge pull request #64 from next-engineer/feature/61-ecr-ecs-deploy
Mminzy22 Aug 16, 2025
181bac5
🐛 fix(match): 소스코드 수정 후 테스트 코드 리팩토링이 덜 되서 마저 수정 및 테스트 후 예외처리 패턴 다른 코드 수정
deepInTheWoodz Aug 16, 2025
43e1fc5
Merge pull request #63 from next-engineer/feature/62-api-fix
Mminzy22 Aug 16, 2025
97a8b7a
🏗️ setup: package.json 및 package-lock.json에 semantic-release 관련 패키지 추…
Mminzy22 Aug 16, 2025
7bbe802
♻️ refactor: headerPattern에서 '!'를 추가하여 커밋 메시지 형식 개선
Mminzy22 Aug 16, 2025
092ce09
📦 chore: semantic-release 설정 파일 추가
Mminzy22 Aug 16, 2025
d4dcb39
Merge pull request #66 from next-engineer/feature/semantic-release-setup
Mminzy22 Aug 16, 2025
2eb32ac
🏗️ setup: ecr, ecs repository_dispatch 방식으로 변경 (트리거)
imjwoo Aug 17, 2025
00af0ff
Merge pull request #67 from next-engineer/feature/61-ecr-ecs-deploy
Mminzy22 Aug 17, 2025
dfd2980
✨ feat: ec2.yml 추가 deploy test
hyeminleeee Aug 17, 2025
52d639a
Merge pull request #69 from next-engineer/feature/ec2-deploy-add
Mminzy22 Aug 17, 2025
4a0811a
✨ feat: 애플리케이션 모니터링을 위한 Spring Boot Actuator 추가
Mminzy22 Aug 17, 2025
83afbb5
Merge pull request #70 from next-engineer/feature/add-actuator-health…
imjwoo Aug 17, 2025
726b9ec
🐛 fix: springdoc OpenAPI 엔드포인트 404 오류 해결
Mminzy22 Aug 17, 2025
207198b
Merge pull request #71 from next-engineer/feature/swagger-api-docs-en…
imjwoo Aug 17, 2025
9146f47
📄 docs: readme.md 개정 – 위키 링크/아키텍처 추가
Mminzy22 Aug 17, 2025
57c5ad8
📄 docs: readme.md 네트워크 아키텍처 이미지 추가
Mminzy22 Aug 17, 2025
9a09b04
📄 docs: readme.md 수정 – 위키 링크 업데이트 및 문서 경로 변경
Mminzy22 Aug 17, 2025
53f4652
Merge pull request #73 from next-engineer/feature/72-docs-readme-update
imjwoo Aug 17, 2025
97525ed
🔧 config(gha): 시맨틱 릴리즈 워크플로 추가
Mminzy22 Aug 17, 2025
b8b259f
Merge pull request #74 from next-engineer/feature/semantic-release-wo…
hyeminleeee Aug 17, 2025
698a28e
✨ feat: ec2.yml, ecr.yml 수정
hyeminleeee Aug 17, 2025
464974b
Merge pull request #75 from next-engineer/feature/68-ec2-deploy-add
imjwoo Aug 17, 2025
b57cdcc
🔧 config(actions): 시맨틱 릴리즈 안정화를 위해 checkout에 ref=${{ github.sha }} 및 …
Mminzy22 Aug 17, 2025
522bdf8
Merge pull request #76 from next-engineer/feature/release-checkout-sha
imjwoo Aug 17, 2025
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 .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]


jobs:
build-and-lint:
runs-on: ubuntu-latest

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

- name: Gradle Wrapper 스크립트(gradlew 및 관련 JAR) 무결성 검증
uses: gradle/wrapper-validation-action@v3
timeout-minutes: 2
continue-on-error: true

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Gradle 실행 환경 최적화 + 캐시
uses: gradle/actions/setup-gradle@v4

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

- name: Build (includes spotless/checkstyle/test via `check` dependency)
run: ./gradlew --no-daemon build
env:
SPRING_PROFILES_ACTIVE: test
74 changes: 74 additions & 0 deletions .github/workflows/ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: EC2 Deploy (short)

on:
repository_dispatch:
types: [deploy-ec2]
workflow_dispatch: {}

env:
AWS_REGION: ap-northeast-2
IMAGE: ${{ github.event.client_payload.image_uri || '077672914621.dkr.ecr.ap-northeast-2.amazonaws.com/kickytime-repo:latest' }}
TARGET_TAG_KEY: Role
TARGET_TAG_VALUE: app
PORT: "8080"
HEALTH: "/actuator/health"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

# ✅ 추가된 최소 스텝: 실행중 + 태그(Role=app) + SSM Online 교집합 → ids_list 출력
- name: Resolve running + tagged + SSM-online
id: resolve
shell: bash
run: |
set -euo pipefail
RUNNING_IDS=$(aws ec2 describe-instances \
--region "${AWS_REGION}" \
--filters "Name=tag:${TARGET_TAG_KEY},Values=${TARGET_TAG_VALUE}" "Name=instance-state-name,Values=running" \
--query 'Reservations[].Instances[].InstanceId' --output text | tr '\t' '\n' || true)
SSM_ONLINE_IDS=$(aws ssm describe-instance-information \
--region "${AWS_REGION}" \
--filters "Key=PingStatus,Values=Online" \
--query 'InstanceInformationList[].InstanceId' --output text | tr '\t' '\n' || true)
TARGET_IDS=$(comm -12 <(printf '%s\n' $RUNNING_IDS | sort) <(printf '%s\n' $SSM_ONLINE_IDS | sort) || true)
if [ -z "${TARGET_IDS:-}" ]; then
echo "No targets (running+tagged+ssm-online)."; exit 1
fi
echo "ids_list=$(printf '%s ' $TARGET_IDS)" >> "$GITHUB_OUTPUT"

- name: Run on all tagged instances via SSM (by instance-ids)
env:
IDS_LIST: ${{ steps.resolve.outputs.ids_list }}
run: |
echo "Deploying image: $IMAGE"

aws ssm send-command \
--region $AWS_REGION \
--document-name "AWS-RunShellScript" \
--instance-ids $IDS_LIST \
--cloud-watch-output-config CloudWatchOutputEnabled=true,CloudWatchLogGroupName=/aws/ssm/kickytime \
--parameters '{
"commands": [
"set -e",
"command -v docker >/dev/null 2>&1 || (dnf -y install docker && systemctl enable --now docker)",
"REG=$(echo \"'$IMAGE'\" | cut -d/ -f1)",
"aws ecr get-login-password --region '$AWS_REGION' | docker login --username AWS --password-stdin $REG",
"docker rm -f kickytime || true",
"docker pull \"'$IMAGE'\"",
"docker run -d --name kickytime -p '$PORT':'$PORT' \\",
" -e SPRING_DATASOURCE_URL=\"'${{ secrets.DB_URL }}'\" \\",
" -e SPRING_DATASOURCE_USERNAME=\"'${{ secrets.DB_USERNAME }}'\" \\",
" -e SPRING_DATASOURCE_PASSWORD=\"'${{ secrets.DB_PASSWORD }}'\" \\",
" \"'$IMAGE'\"",
"for i in $(seq 1 60); do curl -fsS http://127.0.0.1:'$PORT$HEALTH' && break || sleep 2; done"
],
"executionTimeout": ["1800"]
}' \
--comment "Deploy $IMAGE"
134 changes: 134 additions & 0 deletions .github/workflows/ecr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: ECR - Build & Push

on:
push:
branches: [main]
workflow_dispatch:

concurrency:
group: ecr-main
cancel-in-progress: false

permissions:
contents: write # repository_dispatch에 필요

env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: kickytime-repo

jobs:
build_and_push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Ensure jq is installed
run: |
sudo apt-get update -y
sudo apt-get install -y jq

# 멀티아치 에뮬레이션(QEMU) 세팅
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS credentials (Access Keys)
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

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

- name: Set TAG from commit SHA
id: tag
run: echo "TAG=${GITHUB_SHA::12}" >> $GITHUB_OUTPUT

- name: Build & Push multi-arch image
id: build
run: |
set -e
REGISTRY="${{ steps.ecr.outputs.registry }}"
TAG="${{ steps.tag.outputs.TAG }}"
IMAGE_URI="$REGISTRY/${{ env.ECR_REPOSITORY }}:$TAG"
LATEST_URI="$REGISTRY/${{ env.ECR_REPOSITORY }}:latest"

docker buildx build \
--platform linux/amd64,linux/arm64 \
--push \
--tag "$IMAGE_URI" \
--tag "$LATEST_URI" \
.

echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_OUTPUT

- name: Verify multi-arch manifest (Fixed)
run: |
set -e
REGISTRY="${{ steps.ecr.outputs.registry }}"
TAG="${{ steps.tag.outputs.TAG }}"
IMAGE_URI="$REGISTRY/${{ env.ECR_REPOSITORY }}:$TAG"

ARCHES=$(docker manifest inspect "$IMAGE_URI" | jq -r '.manifests[]?.platform | "\(.os)/\(.architecture)"' | sort -u)
echo "Manifests:"
echo "$ARCHES"

# 정확한 매칭으로 수정
if ! echo "$ARCHES" | grep -x 'linux/amd64' > /dev/null; then
echo "❌ Missing linux/amd64 in manifest"
echo "Available platforms: $ARCHES"
exit 1
fi

if ! echo "$ARCHES" | grep -x 'linux/arm64' > /dev/null; then
echo "❌ Missing linux/arm64 in manifest"
echo "Available platforms: $ARCHES"
exit 1
fi

echo "✅ Both linux/amd64 and linux/arm64 found"

# repository_dispatch 전송 + HTTP 204 확인
- name: Trigger ECS/EC2 Deploy via repository_dispatch
if: success()
run: |
set -e
image_uri="${{ steps.build.outputs.IMAGE_URI }}"
tag="${{ steps.tag.outputs.TAG }}"
branch="${{ github.ref_name }}"
sha="${{ github.sha }}"

# ECS
resp=$(curl -s -o /tmp/resp.txt -w "%{http_code}" -X POST \
"https://api.github.com/repos/${{ github.repository }}/dispatches" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"event_type\":\"deploy-ecs\",\"client_payload\":{\"image_uri\":\"$image_uri\",\"tag\":\"$tag\",\"branch\":\"$branch\",\"sha\":\"$sha\"}}")
[ "$resp" = "204" ] || (echo "ECS dispatch failed:" && cat /tmp/resp.txt && exit 1)

# EC2
resp2=$(curl -s -o /tmp/resp2.txt -w "%{http_code}" -X POST \
"https://api.github.com/repos/${{ github.repository }}/dispatches" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"event_type\":\"deploy-ec2\",\"client_payload\":{\"image_uri\":\"$image_uri\",\"tag\":\"$tag\",\"branch\":\"$branch\",\"sha\":\"$sha\"}}")
[ "$resp2" = "204" ] || (echo "EC2 dispatch failed:" && cat /tmp/resp2.txt && exit 1)

- name: Summary
run: |
echo "### ✅ ECR Push & Dispatch OK (Multi-arch)" >> $GITHUB_STEP_SUMMARY
echo "- Repo: \`${{ env.ECR_REPOSITORY }}\`" >> $GITHUB_STEP_SUMMARY
echo "- Tag: \`${{ steps.tag.outputs.TAG }}\`" >> $GITHUB_STEP_SUMMARY
echo "- Image: \`${{ steps.build.outputs.IMAGE_URI }}\`" >> $GITHUB_STEP_SUMMARY
echo "- Arches: \`linux/amd64, linux/arm64\`" >> $GITHUB_STEP_SUMMARY
echo "- Sent: \`repository_dispatch: deploy-ecs\`" >> $GITHUB_STEP_SUMMARY
echo "- Sent: \`repository_dispatch: deploy-ec2\`" >> $GITHUB_STEP_SUMMARY
118 changes: 118 additions & 0 deletions .github/workflows/ecs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: ECS - Deploy (dispatch)

on:
repository_dispatch:
types: [deploy-ecs]
workflow_dispatch:

concurrency:
group: ecs-deploy
cancel-in-progress: false

permissions:
contents: read

env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: kickytime-repo
ECS_CLUSTER: kickytime-cluster
ECS_SERVICE: kickytime-task-service
TASK_FAMILY: kickytime-task
CONTAINER_NAME: kickytime-ecr

jobs:
deploy:
runs-on: ubuntu-latest
env:
PAYLOAD_IMAGE_URI: ${{ github.event.client_payload.image_uri }}
PAYLOAD_TAG: ${{ github.event.client_payload.tag }}
PAYLOAD_BRANCH: ${{ github.event.client_payload.branch }}
PAYLOAD_SHA: ${{ github.event.client_payload.sha }}

steps:
- name: Gate - only deploy for main
id: gate
run: |
if [ "$PAYLOAD_BRANCH" = "main" ]; then
echo "GO=true" >> $GITHUB_OUTPUT
else
echo "GO=false" >> $GITHUB_OUTPUT
echo "Non-deploy branch: $PAYLOAD_BRANCH"
fi

- name: Checkout (same commit as build)
if: steps.gate.outputs.GO == 'true'
uses: actions/checkout@v4
with:
ref: ${{ env.PAYLOAD_SHA }}

- name: Configure AWS credentials
if: steps.gate.outputs.GO == 'true'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
if: steps.gate.outputs.GO == 'true'
id: ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Describe current Task Definition
if: steps.gate.outputs.GO == 'true'
run: |
aws ecs describe-task-definition \
--task-definition "${{ env.TASK_FAMILY }}" \
--query 'taskDefinition' > td.json

- name: Patch image & ensure ARM64 platform
if: steps.gate.outputs.GO == 'true'
run: |
jq --arg NAME "${{ env.CONTAINER_NAME }}" --arg IMG "${PAYLOAD_IMAGE_URI}" '
.containerDefinitions |= map(if .name == $NAME then .image = $IMG else . end)
| .runtimePlatform = {"cpuArchitecture":"ARM64","operatingSystemFamily":"LINUX"}
| del(.taskDefinitionArn,.revision,.status,.requiresAttributes,.compatibilities,.registeredAt,.registeredBy)
' td.json > td-new.json

- name: Register new Task Definition
if: steps.gate.outputs.GO == 'true'
id: register
run: |
NEW_TD_ARN=$(aws ecs register-task-definition \
--cli-input-json file://td-new.json \
--query 'taskDefinition.taskDefinitionArn' \
--output text)
echo "TASK_DEF_ARN=$NEW_TD_ARN" >> $GITHUB_OUTPUT

- name: Update service (rolling deployment)
if: steps.gate.outputs.GO == 'true'
run: |
aws ecs update-service \
--cluster "${{ env.ECS_CLUSTER }}" \
--service "${{ env.ECS_SERVICE }}" \
--task-definition "${{ steps.register.outputs.TASK_DEF_ARN }}" \
--force-new-deployment

- name: Wait for deployment (timeout 10m)
if: steps.gate.outputs.GO == 'true'
id: wait
continue-on-error: true
run: |
timeout 600 aws ecs wait services-stable \
--cluster "${{ env.ECS_CLUSTER }}" \
--services "${{ env.ECS_SERVICE }}" || echo "WAIT_FAILED=true" >> $GITHUB_OUTPUT

- name: Summary
if: steps.gate.outputs.GO == 'true'
run: |
if [ "${{ steps.wait.outputs.WAIT_FAILED }}" == "true" ]; then
echo "### ❌ ECS Deploy Failed" >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "### ✅ ECS Deploy Completed (ARM64)" >> $GITHUB_STEP_SUMMARY
echo "- Cluster: \`${{ env.ECS_CLUSTER }}\`"
echo "- Service: \`${{ env.ECS_SERVICE }}\`"
echo "- TD: \`${{ steps.register.outputs.TASK_DEF_ARN }}\`"
echo "- Image: \`${PAYLOAD_IMAGE_URI}\`"
fi
Loading
Loading