|
| 1 | +name: Daily Snapshot Update |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # 每天 UTC 12:30 = 北京时间 20:30(盘后数据更新后) |
| 6 | + - cron: '30 12 * * 1-5' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + update-snapshot: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Fetch latest snapshot |
| 19 | + run: | |
| 20 | + curl -s -o tests/fixtures/snapshot_v3.json \ |
| 21 | + https://hhxg.top/static/data/assistant/skill_snapshot.json |
| 22 | + python3 -c " |
| 23 | + import json |
| 24 | + with open('tests/fixtures/snapshot_v3.json') as f: |
| 25 | + data = json.load(f) |
| 26 | + with open('tests/fixtures/snapshot_v3.json', 'w', encoding='utf-8') as f: |
| 27 | + json.dump(data, f, ensure_ascii=False, indent=2) |
| 28 | + print('Date:', data.get('date', 'unknown')) |
| 29 | + " |
| 30 | +
|
| 31 | + - name: Check for changes |
| 32 | + id: check |
| 33 | + run: | |
| 34 | + if git diff --quiet tests/fixtures/snapshot_v3.json; then |
| 35 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 36 | + else |
| 37 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 38 | + DATE=$(python3 -c "import json; print(json.load(open('tests/fixtures/snapshot_v3.json')).get('date',''))") |
| 39 | + echo "date=$DATE" >> $GITHUB_OUTPUT |
| 40 | + fi |
| 41 | +
|
| 42 | + - name: Commit and push |
| 43 | + if: steps.check.outputs.changed == 'true' |
| 44 | + run: | |
| 45 | + git config user.name "github-actions[bot]" |
| 46 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 47 | + git add tests/fixtures/snapshot_v3.json |
| 48 | + git commit -m "auto update ${{ steps.check.outputs.date }}" |
| 49 | + git push |
0 commit comments