-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (34 loc) · 1.21 KB
/
Copy pathsync-github-data.yml
File metadata and controls
40 lines (34 loc) · 1.21 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
name: Sync GitHub data
on:
schedule:
- cron: '17 */6 * * *' # 每 6 小时同步一次
workflow_dispatch: # 也支持手动点一下触发
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '22'
# ⚠️ 不能用 secrets.GITHUB_TOKEN!
# 它是 GitHub App 安装令牌(ghs_ 开头),作用域仅限本仓库、不代表你的用户身份,
# 查 contributionsCollection(贡献热力图)会拿到空数据。
# 必须在仓库里配置 secrets.GH_PAT = 你自己的 Personal Access Token (classic)。
- name: Build data.js
run: node scripts/build-data.mjs
env:
GH_PAT: ${{ secrets.GH_PAT }}
- name: Commit if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add data.js
if git diff --staged --quiet; then
echo "数据无变化,跳过提交"
else
git commit -m "chore: sync github data [skip ci]"
git push
fi