forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (54 loc) · 1.69 KB
/
Copy pathbuild-feed.yml
File metadata and controls
62 lines (54 loc) · 1.69 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
name: Build Live Feed
on:
schedule:
- cron: "23 */3 * * *"
push:
branches: [main]
paths:
- "data/lessons.json"
- "scripts/build_feed.py"
workflow_dispatch:
permissions:
contents: write
issues: read
pull-requests: read
jobs:
build-feed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Guard against empty lessons.json
run: |
SIZE=$(stat --printf="%s" data/lessons.json)
if [ "$SIZE" -lt 100 ]; then
echo "::error::data/lessons.json is $SIZE bytes — refusing to sync empty/truncated file"
exit 1
fi
COUNT=$(python3 -c "import json; print(len(json.load(open('data/lessons.json'))))")
if [ "$COUNT" -lt 10 ]; then
echo "::error::data/lessons.json has only $COUNT lessons — refusing to sync"
exit 1
fi
echo "Guard passed: $SIZE bytes, $COUNT lessons"
- name: Sync lessons.json to docs/data/
run: cp data/lessons.json docs/data/lessons.json
- name: Build feed
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 scripts/build_feed.py
- name: Commit and push if changed
run: |
git config user.name "misakanet-bot"
git config user.email "bot@misakanet.org"
git add docs/data/lessons.json docs/data/feed.json
if git diff --cached --quiet; then
echo "No changes"
else
git commit -m "chore(data): sync lessons.json + refresh feed"
git push
fi