Update Line Stats #1346
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Line Stats | |
| on: | |
| schedule: | |
| - cron: '0 1-23/3 * * *' # 每 3 小时(在前两个统计后 1 小时,错开执行) | |
| workflow_dispatch: # 允许手动触发 | |
| push: | |
| paths: | |
| - 'svg/line-stats/**' # Go 代码变更时也触发 | |
| jobs: | |
| update-line-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 line stats generator | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| working-directory: ./svg/line-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/line-stats.svg profile/README.md | |
| git diff --staged --quiet && exit 0 | |
| git commit -m "chore: auto-update line 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 |