build-your-own-x/.github/workflows/update-stats.yml
Cameron Crouch ea0ce0872b Add language statistics reporting feature
- Add generate_stats.py script to analyze README.md and extract language distribution
- Generate STATS-main.md with visualized language statistics
- Add GitHub Actions workflow to auto-update stats when README.md changes
2026-01-16 04:25:51 +00:00

42 lines
1.1 KiB
YAML

name: Update Language Statistics
on:
push:
branches:
- main
- master
paths:
- 'README.md'
workflow_dispatch:
jobs:
update-stats:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Generate language statistics
run: python3 .github/scripts/generate_stats.py
- name: Check for changes
id: git-check
run: |
git diff --exit-code STATS-main.md || echo "changed=true" >> $GITHUB_OUTPUT
- name: Commit and push if changed
if: steps.git-check.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add STATS-main.md
git commit -m "Auto-update language statistics [skip ci]"
git push