-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (45 loc) · 1.42 KB
/
code-stats.yml
File metadata and controls
52 lines (45 loc) · 1.42 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
name: Generate Codes Stats
on:
schedule:
- cron: '0 0 * * *' # 每天运行一次
push:
branches:
- main # 仅在 main 分支发生变化时运行
workflow_dispatch: # 允许手动触发
permissions:
contents: write
issues: write
jobs:
update-code-stats:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{secrets.PERSONAL_ACCESS_TOKEN}} # 使用 PAT 以访问完整的提交历史
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Daily Codes Stats
uses: Talljack/daily-code-stats@main
env:
token: ${{secrets.PERSONAL_ACCESS_TOKEN}} # 使用 PAT 以访问 private repos
- name: Commit files
id: commit-files
run: |
if [ -n "$(git status --porcelain README.md)" ]; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
git commit -m "Update README.md"
echo "hasChange=true" >> $GITHUB_OUTPUT
else
echo "No Changes"
fi
- name: Push changes
uses: ad-m/github-push-action@master
if: ${{ steps.commit-files.outputs.hasChange == 'true' }}
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
branch: ${{ github.ref }}