Skip to content

Update Problem Solving Statistics #54

Update Problem Solving Statistics

Update Problem Solving Statistics #54

Workflow file for this run

name: Update Problem Solving Statistics
on:
schedule:
# 11:00 PM BDT = 17:00 UTC (change via TZ_OFFSET if needed)
- cron: '0 17 * * *'
workflow_dispatch:
env:
TZ_NAME: Asia/Dhaka
PY_VER: '3.12'
README_PATH: docs/README.md
COUNT_PATH: data/last_known_counts.json
WORKFLOW_PATH: .github/workflows/update-stats.yml
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: ${{ env.PY_VER }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install -r requirements.txt
- name: Get GitHub username from config
run: |
python3 -c "
import sys
sys.path.append('src')
from src import GITHUB_USERINFO
print(f'GIT_USER_USERNAME={GITHUB_USERINFO[\"username\"]}')
" >> $GITHUB_ENV
- name: Check and adjust schedule based on activity
run: |
python3 scripts/check_and_adjust_schedule.py
- name: Fetch latest statistics and update README
run: |
echo "Before update:"
stat -c '%y' $README_PATH || ls -l $README_PATH
python3 scripts/auto_update.py
echo "After update:"
stat -c '%y' $README_PATH || ls -l $README_PATH
git diff $README_PATH | head -20
- name: Configure Git
run: |
git config --local user.name "${{ env.GIT_USER_USERNAME }}"
git config --local user.email "${{ env.GIT_USER_USERNAME }}@users.noreply.github.com"
- name: Commit and push if changed
run: |
git add $README_PATH $COUNT_PATH $WORKFLOW_PATH
if git diff --staged --quiet; then
echo "No changes"
else
git commit \
--author="${{ env.GIT_USER_USERNAME }} <${{ env.GIT_USER_USERNAME }}@users.noreply.github.com>" \
-m "Auto-update: Problem solving statistics ($(TZ='${{ env.TZ_NAME }}' date +'%Y-%m-%d %H:%M:%S'))"
git push
fi