Update Problem Solving Statistics #50
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 Problem Solving Statistics | |
| on: | |
| schedule: | |
| # Run every day at 11:00 PM BDT (17:00 UTC) | |
| - cron: '0 17 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| update-stats: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required to push changes to repository | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Check and adjust schedule based on activity | |
| run: | | |
| python3 scripts/check_and_adjust_schedule.py | |
| - name: Fetch latest statistics and update README | |
| id: fetch_stats | |
| run: | | |
| echo "Before update - README last modified:" | |
| stat -c '%y' docs/README.md || ls -l docs/README.md | |
| python3 scripts/auto_update.py 2>&1 | tee stats_output.txt | |
| echo "After update - README last modified:" | |
| stat -c '%y' docs/README.md || ls -l docs/README.md | |
| echo "Checking if README was modified:" | |
| git diff docs/README.md | head -20 | |
| - name: Configure Git | |
| run: | | |
| # Try to get author info from src/config.json, fallback to defaults | |
| if [ -f src/config.json ]; then | |
| AUTHOR_NAME=$(python3 -c "import json; data=json.load(open('src/config.json')); print(data.get('USER_INFO', {}).get('name', 'GitHub Actions'))" 2>/dev/null || echo "GitHub Actions") | |
| AUTHOR_EMAIL=$(python3 -c "import json; data=json.load(open('src/config.json')); print(data.get('USER_INFO', {}).get('email', 'actions@github.com'))" 2>/dev/null || echo "actions@github.com") | |
| else | |
| AUTHOR_NAME="GitHub Actions" | |
| AUTHOR_EMAIL="actions@github.com" | |
| fi | |
| echo "🔧 Configuring git with author: $AUTHOR_NAME <$AUTHOR_EMAIL>" | |
| git config --global user.name "$AUTHOR_NAME" | |
| git config --global user.email "$AUTHOR_EMAIL" | |
| echo "✅ Git configured successfully" | |
| - name: Commit and push if changed | |
| run: | | |
| echo "Checking for changes..." | |
| git status | |
| git add docs/README.md data/last_known_counts.json .github/workflows/update-stats.yml | |
| echo "Files staged. Checking diff..." | |
| git diff --staged --stat | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| echo "Changes detected, committing..." | |
| git commit -m "Auto-update: Problem solving statistics ($(date +'%Y-%m-%d'))" | |
| git push | |
| fi |