Merge pull request #196 from SheetMetalConnect/claude/create-claude-m… #37
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 Repository Stats | |
| on: | |
| push: | |
| branches: [ main ] | |
| schedule: | |
| - cron: '0 0 * * 0' # Weekly on Sunday | |
| workflow_dispatch: | |
| jobs: | |
| update-stats: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history for accurate stats | |
| - name: Calculate Stats | |
| id: stats | |
| run: | | |
| # Total commits | |
| COMMITS=$(git rev-list --count HEAD) | |
| echo "commits=$COMMITS" >> $GITHUB_OUTPUT | |
| # First commit date (inception) | |
| INCEPTION=$(git log --reverse --format="%as" | head -1) | |
| echo "inception=$INCEPTION" >> $GITHUB_OUTPUT | |
| # Lines of code (TypeScript/JavaScript/CSS) | |
| LOC=$(find src -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.css" \) -exec cat {} + 2>/dev/null | wc -l) | |
| LOC=${LOC:-0} | |
| if [ "$LOC" -gt 1000 ]; then | |
| LOC_K=$((LOC / 1000)) | |
| echo "loc=${LOC_K}K" >> $GITHUB_OUTPUT | |
| else | |
| echo "loc=$LOC" >> $GITHUB_OUTPUT | |
| fi | |
| # Commits in last 30 days | |
| RECENT=$(git rev-list --count --since="30 days ago" HEAD) | |
| echo "recent=$RECENT" >> $GITHUB_OUTPUT | |
| - name: Update README | |
| run: | | |
| # Update badges in README | |
| sed -i 's/!\[Commits\](https:\/\/img.shields.io\/badge\/commits-[^)]*)//' README.md | |
| sed -i 's/!\[Inception\](https:\/\/img.shields.io\/badge\/inception-[^)]*)//' README.md | |
| sed -i 's/!\[LOC\](https:\/\/img.shields.io\/badge\/lines-[^)]*)//' README.md | |
| sed -i 's/!\[Velocity\](https:\/\/img.shields.io\/badge\/last_30d-[^)]*)//' README.md | |
| - name: Commit changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git diff --quiet README.md || (git add README.md && git commit -m "chore: update stats [skip ci]" && git push) |