Skip to content

Update Problem Solving Statistics #55

Update Problem Solving Statistics

Update Problem Solving Statistics #55

Workflow file for this run

name: Update Problem Solving Statistics
on:
schedule:
# Run every day at 11:00 PM BDT (17:00 UTC)
- cron: '0 17 * * *'
workflow_dispatch:
jobs:
update-stats:
runs-on: ubuntu-latest
permissions:
contents: write
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
# ==========================
# AUTO GITHUB USER CONFIG
# ==========================
- name: Configure Git Identity
run: |
USERNAME="${GITHUB_ACTOR}"
echo "Using GitHub username: $USERNAME"
git config --local user.name "$USERNAME"
git config --local user.email "$USERNAME@users.noreply.github.com"
# ==========================
# COMMIT WITH BDT TIME
# ==========================
- 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 \
--author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" \
-m "Auto-update: Problem solving statistics ($(TZ='Asia/Dhaka' date +'%Y-%m-%d %H:%M:%S'))"
git push
fi