Skip to content

Commit fcd3a80

Browse files
CopilotMishkatIT
andcommitted
Restore GitHub Actions auto-update with hybrid approach
Co-authored-by: MishkatIT <125080003+MishkatIT@users.noreply.github.com>
1 parent 3eca805 commit fcd3a80

3 files changed

Lines changed: 641 additions & 1 deletion

File tree

.github/workflows/update-stats.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Update Problem Solving Statistics
2+
3+
on:
4+
schedule:
5+
# Run every week on Sunday at 00:00 UTC
6+
- cron: '0 0 * * 0'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
jobs:
10+
update-stats:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Fetch latest statistics
23+
id: fetch_stats
24+
run: |
25+
python3 update_stats.py > stats_output.txt 2>&1 || true
26+
cat stats_output.txt
27+
28+
# Extract JSON output
29+
sed -n '/JSON Output:/,${p;/^}$/q}' stats_output.txt | tail -n +2 > stats.json
30+
cat stats.json
31+
32+
- name: Update README if stats were fetched
33+
run: |
34+
if [ -f stats.json ]; then
35+
echo "Statistics file found, updating README..."
36+
python3 update_readme.py
37+
else
38+
echo "No statistics file found, skipping README update"
39+
fi
40+
41+
- name: Commit and push if changed
42+
run: |
43+
git config --global user.name 'GitHub Action'
44+
git config --global user.email 'action@github.com'
45+
git add README.md last_known_counts.json
46+
if git diff --staged --quiet; then
47+
echo "No changes to commit"
48+
else
49+
git commit -m "Auto-update: Problem solving statistics ($(date +'%Y-%m-%d'))"
50+
git push
51+
fi

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,23 @@
127127

128128
## 📝 How to Update Statistics
129129

130-
This repository tracks problem-solving statistics manually. To update:
130+
This repository tracks problem-solving statistics using a hybrid approach:
131+
132+
### Automatic Updates (GitHub Actions)
133+
- Runs weekly on Sundays at 00:00 UTC
134+
- Automatically fetches statistics from platforms with working APIs
135+
- Failed platforms fall back to last known values with date stamps
136+
- Updates are pushed automatically to the repository
137+
138+
### Manual Updates
139+
If you need to update statistics manually:
131140

132141
1. Run `python3 manual_update.py` to input current statistics
133142
2. The script will prompt you to visit each platform and enter the current solve count
134143
3. Statistics are automatically saved and the README is updated
135144

145+
**Note:** Each platform shows the last update date in small text when using cached values.
146+
136147
---
137148

138149
<div align="center">

0 commit comments

Comments
 (0)