Skip to content

Update Problem Solving Statistics #243

Update Problem Solving Statistics

Update Problem Solving Statistics #243

Workflow file for this run

name: Update Problem Solving Statistics
on:
# DYNAMIC_SCHEDULE_START
schedule:
- cron: '35 16 * * *'
# DYNAMIC_SCHEDULE_END
workflow_dispatch:
# ==========================
# GLOBAL TIMEZONE (BDT)
# ==========================
env:
TZ: Asia/Dhaka
jobs:
update-stats:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# ==========================
# AUTO GITHUB OWNER CONFIG
# ==========================
- name: Configure Git Identity
run: |
OWNER="${GITHUB_REPOSITORY_OWNER}"
echo "Using repository owner: $OWNER"
git config --local user.name "$OWNER"
git config --local user.email "$OWNER@users.noreply.github.com"
- 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: 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
# ==========================
# COMMIT + PUSH (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_REPOSITORY_OWNER <$GITHUB_REPOSITORY_OWNER@users.noreply.github.com>" \
-m "Auto-update: Problem solving statistics ($(date +'%Y-%m-%d %H:%M:%S'))"
git push
fi