fix: subject 필드 누락으로 인한 빌드 오류 수정 #58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Embeddings | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'content' | |
| workflow_dispatch: | |
| jobs: | |
| embeddings: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| token: ${{ secrets.GH_PAT }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - run: npm ci | |
| - name: Detect changed markdown posts | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| CHANGED_FILE_LIST=".github/changed-posts.txt" | |
| BEFORE_SHA="${{ github.event.before }}" | |
| AFTER_SHA="${{ github.sha }}" | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" || "$BEFORE_SHA" =~ ^0+$ ]]; then | |
| echo "__FULL__" > "$CHANGED_FILE_LIST" | |
| exit 0 | |
| fi | |
| OLD_CONTENT_SHA="$(git ls-tree "$BEFORE_SHA" content | awk '{print $3}')" | |
| NEW_CONTENT_SHA="$(git ls-tree "$AFTER_SHA" content | awk '{print $3}')" | |
| if [[ -z "$OLD_CONTENT_SHA" || -z "$NEW_CONTENT_SHA" ]]; then | |
| echo "__FULL__" > "$CHANGED_FILE_LIST" | |
| exit 0 | |
| fi | |
| git -C content fetch --no-tags origin "$OLD_CONTENT_SHA" "$NEW_CONTENT_SHA" || true | |
| if ! git -C content cat-file -e "$OLD_CONTENT_SHA^{commit}" || ! git -C content cat-file -e "$NEW_CONTENT_SHA^{commit}"; then | |
| echo "__FULL__" > "$CHANGED_FILE_LIST" | |
| exit 0 | |
| fi | |
| RAW_CHANGED_FILE_LIST="$(mktemp)" | |
| git -C content diff --name-status "$OLD_CONTENT_SHA" "$NEW_CONTENT_SHA" -- posts > "$RAW_CHANGED_FILE_LIST" | |
| body_from_ref() { | |
| local ref="$1" | |
| local file="$2" | |
| git -C content show "$ref:$file" 2>/dev/null | awk ' | |
| NR == 1 && $0 == "---" { in_frontmatter = 1; next } | |
| in_frontmatter && $0 == "---" { in_frontmatter = 0; next } | |
| !in_frontmatter { print } | |
| ' | |
| } | |
| : > "$CHANGED_FILE_LIST" | |
| while IFS=$'\t' read -r status path_one path_two; do | |
| [[ -z "$status" ]] && continue | |
| if [[ "$status" == "D" ]]; then | |
| [[ "$path_one" == *.md ]] && printf '%s\t%s\n' "$status" "$path_one" >> "$CHANGED_FILE_LIST" | |
| continue | |
| fi | |
| if [[ "$status" == R* || "$status" == C* ]]; then | |
| [[ "$path_one" == *.md ]] && printf 'D\t%s\n' "$path_one" >> "$CHANGED_FILE_LIST" | |
| old_path="$path_one" | |
| new_path="$path_two" | |
| else | |
| old_path="$path_one" | |
| new_path="$path_one" | |
| fi | |
| [[ "$new_path" == *.md ]] || continue | |
| if [[ "$status" == "A" ]]; then | |
| printf '%s\t%s\n' "$status" "$new_path" >> "$CHANGED_FILE_LIST" | |
| continue | |
| fi | |
| old_body="$(body_from_ref "$OLD_CONTENT_SHA" "$old_path")" | |
| new_body="$(body_from_ref "$NEW_CONTENT_SHA" "$new_path")" | |
| if [[ "$old_body" != "$new_body" ]]; then | |
| printf '%s\t%s\n' "$status" "$new_path" >> "$CHANGED_FILE_LIST" | |
| fi | |
| done < "$RAW_CHANGED_FILE_LIST" | |
| - name: Generate & upsert embeddings | |
| env: | |
| COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} | |
| SUPABASE_URL: ${{ secrets.SUPABASE_URL }} | |
| SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }} | |
| run: npm run embeddings:changed |