Update comic_easter_egg.py #1825
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 README Stats | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - '**.py' # Only run if Python files changed | |
| schedule: | |
| - cron: '0 2 * * 0' # Weekly on Sunday at 2 AM UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-readme: | |
| name: Calculate and Update Stats | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Count Python files and lines | |
| id: stats | |
| run: | | |
| PY_FILES=$(find . -name "*.py" -type f | wc -l) | |
| TOTAL_LINES=$(find . -name "*.py" -type f -exec cat {} + | wc -l) | |
| echo "py_files=$PY_FILES" >> $GITHUB_OUTPUT | |
| echo "total_lines=$TOTAL_LINES" >> $GITHUB_OUTPUT | |
| echo "π Found $PY_FILES Python files with $TOTAL_LINES total lines" | |
| - name: Update README.md | |
| run: | | |
| STATS="π Total lines of code: ${{ steps.stats.outputs.total_lines }}\nπ Number of Python files: ${{ steps.stats.outputs.py_files }}" | |
| DATE="π Last updated: $(date -u +"%Y-%m-%d %H:%M UTC")" | |
| sed -i "/<!-- STATS:START -->/,/<!-- STATS:END -->/c\\<!-- STATS:START -->\n$STATS\n<!-- STATS:END -->" README.md | |
| sed -i "/<!-- UPDATED:START -->/,/<!-- UPDATED:END -->/c\\<!-- UPDATED:START -->\n$DATE\n<!-- UPDATED:END -->" README.md | |
| - name: Commit and push changes | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| if git diff --quiet README.md; then | |
| echo "β No changes to README" | |
| exit 0 | |
| fi | |
| git add README.md | |
| git commit -m "docs: update README stats [skip ci]" | |
| git push |