Update GitHub Data #69
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 GitHub Data | |
| on: | |
| schedule: | |
| # 每 6 小时运行一次 | |
| - cron: "0 */6 * * *" | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - "scripts/fetch-gh-data.ts" | |
| permissions: | |
| contents: write | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - uses: pnpm/action-setup@v5 | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Fetch GitHub data | |
| run: pnpm fetch:ghdata | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for changes | |
| id: check | |
| run: | | |
| git diff --exit-code src/ghdata.json || echo "changed=true" >> $GITHUB_OUTPUT | |
| - name: Commit and push | |
| if: steps.check.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add src/ghdata.json | |
| git commit -m "chore: update GitHub data" | |
| git push |