Skip to content

Update Stats

Update Stats #186

Workflow file for this run

name: Update Stats
on:
push:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Count all tips and update stats
run: |
laravel_tips=$(grep -r "^## Laravel Tip" ./tips | wc -l)
php_tips=$(grep -r "^## PHP Tip" ./tips | wc -l)
pest_tips=$(grep -r "^## Pest Tip" ./tips | wc -l)
# Calculate total
total=$((laravel_tips + php_tips + pest_tips))
echo "{\"totalTips\": $total}" > stats.json
echo "Found $laravel_tips Laravel tips, $php_tips PHP tips, $pest_tips Pest tips, total: $total"
- name: Commit and push if changed
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git add stats.json
git diff --quiet && git diff --staged --quiet || (git commit -m "Update tip count" && git push)