Skip to content

Update Code Byte Stats #460

Update Code Byte Stats

Update Code Byte Stats #460

name: Update Code Byte Stats
on:
schedule:
- cron: '0 */3 * * *' # 每 3 小时自动运行
workflow_dispatch: # 允许手动触发
push:
paths:
- 'svg/byte-stats/**' # Go 代码变更时也触发
jobs:
update-byte-stats:
runs-on: ubuntu-latest
permissions:
contents: write # 需要写权限来提交文件
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
- name: Run byte stats generator
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./svg/byte-stats
run: go run main.go
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -f profile/byte-stats.svg profile/README.md
git diff --staged --quiet && exit 0
git commit -m "chore: auto-update byte stats [skip ci]"
for i in 1 2 3; do
git pull --rebase origin main && git push && break
echo "Retry $i..."
sleep $((i * 5))
done