1+ name : Monthly Script Runner
2+
3+ # 触发条件:每月的1号运行
4+ on :
5+ schedule :
6+ - cron : " 0 0 0 * *" # 每月一号的00:00 UTC时间运行
7+ workflow_dispatch :
8+
9+ jobs :
10+ run-scripts :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ # 检出代码
15+ - name : Checkout repository
16+ uses : actions/checkout@v4
17+
18+ # 设置 Node.js 环境
19+ - name : Set up Node.js
20+ uses : actions/setup-node@v4
21+ with :
22+ node-version : ' 20' # 使用 Node.js 18
23+
24+ # 运行第一个脚本 sync_xlab.js,从接口获取最新数据
25+ - name : Run sync_xlab.js
26+ run : node script/sync_xlab.js
27+
28+ # 运行第二个脚本 update_year_user.js, 更新 rankingList.json
29+ - name : Run update_year_user.js
30+ run : node script/update_year_user.js
31+ env :
32+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
33+
34+ # 运行第三个脚本 front-matter.js, 批量创建详情页
35+ - name : Run front-matter.js
36+ run : node script/front-matter.js
37+
38+ # 提交并推送更改到 main 分支
39+ - name : Commit and push changes
40+ run : |
41+ git config --local user.email "action@github.com"
42+ git config --local user.name "GitHub Action"
43+ git add .
44+ git commit -m "chore: Automated data update from scripts"
45+ git push origin main
46+ env :
47+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
48+
49+ # # 创建并推送 PR
50+ # - name: Create Pull Request
51+ # id: create_pr
52+ # uses: peter-evans/create-pull-request@v7
53+ # with:
54+ # commit-message: "chore: Updating data from xlab"
55+ # title: "chore: Updating data from xlab"
56+ # body: "Updating data from xlab,and create user homepages"
57+ # branch: update-ranking-data
58+ # base: "main"
59+ # delete-branch: true
60+
61+ # # 启用自动合并
62+ # - name: Enable auto-merge
63+ # uses: peter-evans/enable-pull-request-automerge@v3
64+ # with:
65+ # token: ${{ secrets.GITHUB_TOKEN }}
66+ # pull-request-number: ${{ steps.create_pr.outputs.pull-request-number }}
67+ # merge-method: merge
0 commit comments