Skip to content
Draft
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
10 changes: 9 additions & 1 deletion .github/workflows/_collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: "수집에 쓸 브랜치"
type: string
required: true
source:
description: "수집 소스(collector.source). ALL / CALENDAR 등"
type: string
default: ALL

permissions:
contents: read
Expand All @@ -23,7 +27,7 @@ jobs:
ref: ${{ inputs.ref }}

collect:
name: Collect into ${{ inputs.environment }}
name: Collect ${{ inputs.source }} into ${{ inputs.environment }}
needs: ci
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
Expand Down Expand Up @@ -53,6 +57,8 @@ jobs:
uses: gradle/actions/setup-gradle@v6

- name: Install Chromium for bank URL scraping
# 캘린더 수집은 은행 URL 스크래핑을 하지 않는다.
if: inputs.source != 'CALENDAR'
run: |
bash ./gradlew playwrightInstall
npx -y playwright@1.61.0 install-deps chromium
Expand Down Expand Up @@ -85,7 +91,9 @@ jobs:
SPRING_DATASOURCE_URL: jdbc:postgresql://127.0.0.1:15432/database
SPRING_DATASOURCE_USERNAME: user
SPRING_DATASOURCE_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
COLLECTOR_SOURCE: ${{ inputs.source }}
FSS_API_KEY: ${{ secrets.FSS_API_KEY }}
ONTONG_YOUTH_API_KEY: ${{ secrets.ONTONG_YOUTH_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
LLM_ENABLED: "true"
# 배치가 FAILED면 0이 아닌 코드로 끝나 이 단계가 실패한다(ApiCollectorApplication.main).
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/calendar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Calendar

# B1 캘린더 데이터(정책상품 회차, 온통청년 청년정책)만 매일 갱신한다(COLLECTOR_SOURCE=CALENDAR).
# PRD: 하루 1회 이상 수집하고 B2 알림 메일(09:00 KST) 발송 전에 끝낸다.
# LLM·은행 스크래핑을 쓰지 않아 매일 돌려도 API 비용이 없다. 설정은 CLAUDE.md의 "수집 워크플로" 참고.
on:
schedule:
# 20:17 UTC = 05:17 KST. 정각은 Actions 스케줄이 몰려 늦게 시작하는 일이 많아 피한다.
# 2주 수집(collect.yml, 04:00 KST)과 겹치면 collect-<env> 동시 실행 그룹에서 그 뒤에 돈다.
- cron: "17 20 * * *"
workflow_dispatch:
inputs:
environment:
description: "수집 대상 환경"
type: choice
options: [dev, prod]
default: dev

permissions:
contents: read

jobs:
dev:
if: github.event_name == 'schedule' || inputs.environment == 'dev'
uses: ./.github/workflows/_collect.yml
secrets: inherit
permissions:
contents: read
id-token: write
with:
environment: dev
ref: main
source: CALENDAR

prod:
if: vars.PROD_ENABLED == 'true' && (github.event_name == 'schedule' || inputs.environment == 'prod')
uses: ./.github/workflows/_collect.yml
secrets: inherit
permissions:
contents: read
id-token: write
with:
environment: prod
ref: release
source: CALENDAR
8 changes: 5 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ api-collector main에 박히는 포인터는 **Fin-BE main에 머지된 커밋**
1. Fin-BE 스키마 변경을 main에 머지
2. `git submodule update --remote fin-be` → 포인터 bump 후 커밋

## 수집 워크플로 (`.github/workflows/collect.yml`)
## 수집 워크플로 (`.github/workflows/collect.yml`, `calendar.yml`)

수집 배치는 서버가 아니라 GitHub Actions 러너에서 돈다(서버 e2-micro에는 Chromium을 띄울 여유가 없음).
두 워크플로 모두 `_collect.yml`을 호출하고, `source` 입력이 `COLLECTOR_SOURCE`(collector.source)가 된다.

- 주기: LLM API 비용 때문에 약 2주 간격(매월 2·16일 04:00 KST). 그 사이에는 Actions에서 수동 실행(`workflow_dispatch`).
- `collect.yml`(`ALL`): LLM API 비용 때문에 약 2주 간격(매월 2·16일 04:00 KST). 그 사이에는 Actions에서 수동 실행(`workflow_dispatch`).
- `calendar.yml`(`CALENDAR`): B1 캘린더(정책상품 회차, 온통청년 청년정책)만 매일 05:17 KST. B2 알림 메일(09:00 KST) 전에 끝내야 한다. LLM·Chromium을 쓰지 않는다.
- `main` → dev DB, `release` → 운영 DB. 운영은 레포 변수 `PROD_ENABLED=true`일 때만 돈다.
- 수집 전에 같은 브랜치로 `ci.yml`(테스트)을 돌리고, 통과해야 수집한다.
- 서버 접속: GCP OIDC 인증 → IAP SSH 포트 포워딩으로 서버 Postgres(`127.0.0.1:5678`)에 붙는다. 서버 구성과 GCP 설정은 Fin-BE `docs/implementation/deployment.md`.
- GitHub Environment(`dev`, `prod`): vars `GCP_PROJECT`, `GCP_WIF_PROVIDER`, `GCP_SERVICE_ACCOUNT`, `GCE_INSTANCE`, `GCE_ZONE` / secrets `POSTGRES_PASSWORD`, `FSS_API_KEY`, `GEMINI_API_KEY`.
- GitHub Environment(`dev`, `prod`): vars `GCP_PROJECT`, `GCP_WIF_PROVIDER`, `GCP_SERVICE_ACCOUNT`, `GCE_INSTANCE`, `GCE_ZONE` / secrets `POSTGRES_PASSWORD`, `FSS_API_KEY`, `GEMINI_API_KEY`, `ONTONG_YOUTH_API_KEY`.
- **순서 제약**: 엔티티가 새 컬럼을 쓰면 Fin-BE가 그 마이그레이션을 해당 환경에 먼저 배포해야 한다. 아니면 `ddl-auto: validate`에서 수집이 실패한다.
Loading