Update Google Maps Stats #292
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 Google Maps Stats | |
| on: | |
| schedule: | |
| # Run every day at 6 AM UTC | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| update-stats: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v5 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Fetch Google Maps stats | |
| run: pnpm run fetch-maps-stats | |
| - name: Check for changes | |
| id: verify-changed-files | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit updated stats | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add src/utils/googleMapsCache.ts src/data/google-maps-stats.json | |
| git commit -m "chore: update Google Maps statistics [skip ci]" | |
| git push | |
| - name: Trigger website rebuild | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'astro.yml', | |
| ref: 'main' | |
| }) |