-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 1.53 KB
/
upload-models.yml
File metadata and controls
53 lines (46 loc) · 1.53 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
name: Upload models to R2
on:
push:
branches: [main, master]
paths:
- "models/**"
workflow_dispatch:
jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install wrangler
run: npm install -g wrangler@latest
- name: Upload models
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
IS_FIRST_PUSH="${{ github.event.before == '0000000000000000000000000000000000000000' }}"
IS_MANUAL="${{ github.event_name == 'workflow_dispatch' }}"
if [ "$IS_FIRST_PUSH" = "true" ] || [ "$IS_MANUAL" = "true" ]; then
echo "Uploading all model files..."
FILES=$(find models/ -type f)
else
echo "Uploading only changed files..."
FILES=$(git diff --name-only HEAD~1 HEAD -- models/ | grep -v '^$')
fi
if [ -z "$FILES" ]; then
echo "No files to upload."
exit 0
fi
echo "$FILES" | while read file; do
[ -f "$file" ] || continue
key="$file"
echo "Uploading $file → r2://framefind-models/$key"
wrangler r2 object put "framefind-models/$key" \
--file "$file" \
--content-type "application/octet-stream" \
--remote
done