forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (46 loc) · 1.55 KB
/
Copy pathsync-data.yml
File metadata and controls
51 lines (46 loc) · 1.55 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
name: Sync Metadata to data Branch
on:
push:
branches: [main]
paths:
- "data/counter.json"
- "data/lessons.json"
permissions:
contents: read
jobs:
sync:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- 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"
exit 1
fi
- name: Push to data branch
env:
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "misakanet-bot"
git config user.email "bot@misakanet.dev"
git remote set-url origin "https://x-access-token:${GIT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
# Fetch + checkout data branch (use --track to disambiguate from data/ directory)
git fetch origin data
git checkout --track origin/data
# Overwrite with current versions from main
git checkout main -- data/counter.json data/lessons.json
# Commit if changed
if ! git diff --quiet; then
git add data/counter.json data/lessons.json
git commit -m "sync: auto-update metadata from main@$(git rev-parse --short main)"
git push origin data
else
echo "No changes — data branch already up to date"
fi
git checkout main