Repository navigation
77 lines (69 loc) · 2.54 KB
/
Copy pathvectorize-code-embeddings.yml
File metadata and controls
77 lines (69 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Vectorize / Code embeddings
permissions:
contents: read
on:
push:
branches:
- main
# No paths filter — the whole repo is in scope (code, docs, configs, Dockerfiles,
# Tinybird .pipe/.datasource, etc.). embed_code.py's own blocklist decides relevance,
# not the trigger, so every push to main runs the incremental diff below.
workflow_dispatch:
inputs:
mode:
description: 'full = re-embed entire repo (first-time backfill / manual rebuild). incremental = only diff since last run.'
type: choice
options:
- full
- incremental
default: full
jobs:
embed:
runs-on: ubuntu-latest
concurrency:
group: vectorize-code-embeddings
cancel-in-progress: false
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: pip install -q requests tiktoken xxhash
- name: Determine mode and refs
id: params
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "mode=${{ inputs.mode }}" >> "$GITHUB_OUTPUT"
else
echo "mode=incremental" >> "$GITHUB_OUTPUT"
fi
echo "base_sha=${{ github.event.before }}" >> "$GITHUB_OUTPUT"
echo "head_sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
- name: Run full embed
if: steps.params.outputs.mode == 'full'
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.POLLI_VECTOR_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.POLLI_VECTOR_KEY }}
POLLI_VECTOR_DB: ${{ secrets.POLLI_VECTOR_DB }}
run: python apps/polli/scripts/embed_code.py --mode full --repo-root .
- name: Run incremental embed
if: steps.params.outputs.mode == 'incremental'
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.POLLI_VECTOR_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.POLLI_VECTOR_KEY }}
POLLI_VECTOR_DB: ${{ secrets.POLLI_VECTOR_DB }}
run: |
BASE_SHA="${{ steps.params.outputs.base_sha }}"
if [ -z "$BASE_SHA" ] || [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then
BASE_SHA=$(git rev-parse HEAD~1)
fi
python apps/polli/scripts/embed_code.py \
--mode incremental \
--repo-root . \
--base-sha "$BASE_SHA" \
--head-sha "${{ steps.params.outputs.head_sha }}"