Data Sync #5390
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: Data Sync | |
| on: | |
| schedule: | |
| # 每小时的第5分钟运行一次 | |
| - cron: '5 * * * *' | |
| # 允许手动触发 | |
| workflow_dispatch: | |
| jobs: | |
| sync-data: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Fetch GitHub data | |
| run: | | |
| mkdir -p data | |
| bun run scripts/fetch-github-data.ts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | |
| - name: Commit and push if changed | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add data/ | |
| # 检查是否有更改 | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: update GitHub data [skip ci]" | |
| git push | |
| fi |