[ICC-275] Redoc + GitHub Pages API 문서 자동 배포 구축#141
Conversation
- api-docs 전용 프로파일을 test 프로파일로 대체 - application-api-docs.yml 삭제 - application.yml에서 graceful shutdown 설정 제거
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| paths: | ||
| - 'modules/**/src/main/java/**' | ||
| - 'app/src/main/resources/application*.yml' | ||
|
|
There was a problem hiding this comment.
Java 소스 또는 application*.yml 변경 시에만 트리거되도록 paths 필터 적용. README 등 문서만 변경했을 때 불필요한 배포를 방지한다.
| // 예: spring.jpa.hibernate.ddl-auto=validate 설정으로 엔티티와 DB 스키마 일치 여부를 검증 | ||
| implementation "org.springframework.boot:spring-boot-starter-data-jpa" | ||
| implementation 'org.springframework.boot:spring-boot-starter-actuator' | ||
| // H2: CI 환경에서 OpenAPI spec 추출 시 인메모리 DB로 사용 |
There was a problem hiding this comment.
H2는 CI 환경(test 프로파일)에서 OpenAPI spec 추출 시 인메모리 DB로만 사용되므로 runtimeOnly로 선언. 프로덕션 빌드에는 영향 없음.
There was a problem hiding this comment.
임시 파일: 스테이징 안한줄 알았는데 해버렸네요 ㅠㅠ
기존 lambda에서 다시 스프링부트로 통합하기위해 두었습니다
📢 설명
H2 필요한 이유: 스프링부트가 실행되어야해서, 데이터베이스 자체에 쿼리를 날리거나 그런건 아닙니다!!
변경 요약
ci-/cd-접두사로 역할 기반 네이밍 통일.github/workflows/app/build.gradle, 설정 파일.githooks/파일에 실행 권한(755) 추가.githooks/변경 1: CI/CD 워크플로우 파일명 역할 기반 정리
워크플로우 파일이 늘어나면서 파일명만으로 역할을 식별하기 어려워져,
ci-/cd-접두사 + 역할 설명 패턴으로 네이밍 컨벤션을 통일했다.ci.yml→ci-check-code-convention.ymlprod_deploy.yml→cd-prod_deploy.ymlauto-version-bump.yml→ci-auto-version-bump.ymlNote
GitHub Actions는
.github/workflows/하위 디렉토리를 지원하지 않으므로, 파일명 접두사 방식이 사실상 유일한 정리 방법이다.변경 2: Redoc + GitHub Pages API 문서 자동 배포 파이프라인
기존에 노션에 API 명세를 수동 기입하는 방식이었으나, 관리가 안 되는 문제가 있었다. 코드 기반으로 OpenAPI spec을 자동 추출하고 Redoc으로 정적 HTML 문서를 생성하여 GitHub Pages에 배포하는 파이프라인을 구축했다.
동작 흐름:
develop브랜치에 Java 소스 또는application*.yml변경이 push되면 트리거test프로파일(H2 인메모리 DB)로 서버 기동/v3/api-docs에서 OpenAPI spec JSON 추출docs/api/index.html과 함께 GitHub Pages에 배포설정 파일 구조 개편:
application-api-docs.yml삭제 →test프로파일로 통합 (CI와 테스트가 같은 설정을 공유하여 유지보수 부담 제거)application.yml을spring.application.name만 남기고 최소화 (각 프로파일이 독립적으로 전체 설정 보유)app/build.gradle에 H2runtimeOnly의존성 추가💡 의사 선택과정 (trade-off)
API 문서 도구 선정
CI 프로파일 전략
CI 전용 프로파일(→ 설정 변경 시 두 파일 관리 필요api-docs) 별도 유지test프로파일 통합 채택 → CI OpenAPI 추출 + 테스트 코드에서@ActiveProfiles("test")로 공유변경 3: Git hooks 실행 권한 부여
.githooks/pre-commit,prepare-commit-msg의 파일 권한을 644 → 755로 변경. 실행 권한이 없으면core.hooksPath로 설정해도 훅이 동작하지 않을 수 있다.변경 4: application-test.yml 파일을 스테이징 시킴
API 스키마를 추출하기 위해서는 스프링부트를 일시적으로 구동시켜야한다. 그 때 사용할 프로필이다. 동시에 추후 테스트 코드 작성시에 사용할 프로필로도 활용가능하게 여지를 두었다
코드 설명: 인라인 코멘트
✅ 체크리스트
재현 확인
API 문서 배포워크플로우 성공 확인https://q-asker.github.io/api/)에 Redoc 문서가 정상 배포되었는지 확인기본