-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (56 loc) · 1.96 KB
/
sync.yml
File metadata and controls
66 lines (56 loc) · 1.96 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
63
64
65
66
name: Sync Activities (Legacy SQLite)
# DEPRECATED: Migrated to Turso cloud database. See sync-turso.yml.
# Keeping this workflow for reference only.
on:
# schedule:
# - cron: '0 0 * * *'
# workflow_dispatch:
workflow_dispatch:
inputs:
confirm:
description: 'This workflow is deprecated. Use sync-turso.yml instead.'
required: true
default: 'I understand this is deprecated'
permissions:
contents: write # 允许写入仓库内容
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
# 使用 PAT (Personal Access Token) 以获得推送权限
# 如果没有设置 PAT,则回退到默认的 GITHUB_TOKEN
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Install Playwright browsers
run: bunx playwright install chromium --with-deps
- name: Run sync script
env:
DATABASE_URL: file:./data/activities.db
STRAVA_CLIENT_ID: ${{ secrets.STRAVA_CLIENT_ID }}
STRAVA_CLIENT_SECRET: ${{ secrets.STRAVA_CLIENT_SECRET }}
STRAVA_REFRESH_TOKEN: ${{ secrets.STRAVA_REFRESH_TOKEN }}
run: bun run sync
- name: Check for changes
id: check_changes
run: |
if git diff --quiet data/activities.db; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add data/activities.db
git commit -m "chore: Update activities database"
git push