-
Notifications
You must be signed in to change notification settings - Fork 57
55 lines (50 loc) · 1.77 KB
/
sync-embeddings.yml
File metadata and controls
55 lines (50 loc) · 1.77 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
name: Sync Support Embeddings
on:
push:
branches:
- main
paths:
- "docs/**/*.mdx"
- "help/**/*.mdx"
jobs:
sync:
name: Re-embed changed articles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Find changed MDX files
id: changed
run: |
CHANGED=$(git diff --name-only HEAD~1 HEAD -- 'docs/**/*.mdx' 'help/**/*.mdx' | tr '\n' ' ')
echo "files=$CHANGED" >> $GITHUB_OUTPUT
echo "Changed files: $CHANGED"
- name: Re-embed changed articles
if: steps.changed.outputs.files != ''
env:
EMBEDDING_SYNC_SECRET: ${{ secrets.EMBEDDING_SYNC_SECRET }}
run: |
for file in ${{ steps.changed.outputs.files }}; do
# Map file path to public URL
# docs/api-reference/links/create.mdx → https://dub.co/docs/api-reference/links/create
# help/article/partner-payouts.mdx → https://dub.co/help/article/partner-payouts
if [[ "$file" == docs/* ]]; then
path="${file#docs/}"
path="${path%.mdx}"
url="https://dub.co/docs/$path"
elif [[ "$file" == help/* ]]; then
path="${file#help/}"
path="${path%.mdx}"
url="https://dub.co/help/$path"
else
continue
fi
echo "Re-embedding: $url"
curl -sf -X POST https://app.dub.co/api/ai/sync-embeddings \
-H "Authorization: Bearer $EMBEDDING_SYNC_SECRET" \
-H "Content-Type: application/json" \
-d "{\"url\": \"$url\", \"delay\": 600}" \
&& echo " ✓ Done" \
|| echo " ✗ Failed (exit $?)"
done