Skip to content

Commit 6671911

Browse files
Merge pull request #1 from phoenixcodeforces-blip/completeWorkflow
complete
2 parents 0b65442 + 7e2fc69 commit 6671911

File tree

8 files changed

+629
-0
lines changed

8 files changed

+629
-0
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# GitHub Activity Automation - Implementation Summary
2+
3+
## ✅ Issues Fixed
4+
5+
### 1. **Missing Core Functions** - RESOLVED
6+
- ✅ Implemented `ensure_directories()` - Creates data/logs, data/stats, data/quotes directories
7+
- ✅ Implemented `load_config()` - Loads configuration from activity_config.json with multiple path fallbacks
8+
- ✅ Implemented `update_daily_log()` - Creates daily activity logs with timestamps and random activities
9+
- ✅ Implemented `update_stats()` - Maintains repository statistics with realistic metrics
10+
- ✅ Implemented `update_quote_file()` - Adds inspirational programming quotes with timestamps
11+
12+
### 2. **Missing Import Statements** - RESOLVED
13+
- ✅ Added `import random` for randomization
14+
- ✅ Added `import json` for configuration loading
15+
- ✅ Added `import os` for directory operations
16+
- ✅ Added `from datetime import datetime, timedelta` for timestamps
17+
18+
### 3. **Missing Main Function Call** - RESOLVED
19+
- ✅ Added `if __name__ == "__main__": main()` at the end of the script
20+
21+
### 4. **Workflow Path Issues** - RESOLVED
22+
- ✅ Fixed script path in workflow: `python .github/scripts/update_activity.py`
23+
- ✅ Added proper change detection and conditional commit logic
24+
- ✅ Improved error handling in GitHub Actions workflow
25+
26+
### 5. **Configuration Updates** - RESOLVED
27+
- ✅ Updated target commit range: 4-26 commits daily (was 8-18)
28+
- ✅ Adjusted max_changes_per_run to 3 for more realistic commits
29+
- ✅ Updated skip rate to 40% for better variance
30+
31+
## 🚀 How It Works Now
32+
33+
### **Daily Operation**
34+
1. **12 scheduled runs per day** at random intervals (every 2-3 hours)
35+
2. **40% random skip rate** for natural variance
36+
3. **1-3 changes per run** when executed
37+
4. **Realistic commit messages** with different date formats
38+
39+
### **Generated Content**
40+
1. **Activity Logs** (`data/logs/activity_YYYY-MM-DD.log`)
41+
- Timestamps with random development activities
42+
- Examples: "Code review and optimization", "Bug fixes and improvements"
43+
44+
2. **Statistics** (`data/stats/repository_stats.json`)
45+
- Daily commit counts, lines added/removed, files changed
46+
- Auto-cleanup after 30 days
47+
48+
3. **Quotes** (`data/quotes/daily_quotes.txt`)
49+
- 15 inspirational programming quotes
50+
- Timestamped entries
51+
52+
### **Commit Messages**
53+
Generated with 14 different templates and 4 date formats:
54+
- "Update activity log - 2025-09-01"
55+
- "Daily maintenance - Sep 01"
56+
- "Repository maintenance 2025/09/01"
57+
- "Activity tracking update" (no date)
58+
59+
## 📊 Expected Results
60+
61+
### **Commit Range: 4-26 per day**
62+
- **Minimum**: 4 commits (when most runs are skipped)
63+
- **Maximum**: 26 commits (when all runs execute with max changes)
64+
- **Average**: ~12-15 commits per day
65+
66+
### **Natural Variance**
67+
- Random execution times throughout the day
68+
- Different activities and quotes each time
69+
- Realistic development patterns
70+
71+
## 🔧 Configuration
72+
73+
### **activity_config.json**
74+
```json
75+
{
76+
"enabled": true,
77+
"update_types": ["log", "stats", "quote"],
78+
"max_changes_per_run": 3,
79+
"schedule": {
80+
"commits_per_day_min": 4,
81+
"commits_per_day_max": 26
82+
}
83+
}
84+
```
85+
86+
### **Customization Options**
87+
- **Enable/disable**: Set `"enabled": false` to turn off
88+
- **Commit range**: Adjust min/max values
89+
- **Update types**: Add/remove log, stats, quote
90+
- **Skip rate**: Modify the 0.40 value in the script
91+
92+
## 🛠️ Files Created/Modified
93+
94+
### **New Files**
95+
-`.github/scripts/update_activity.py` (complete implementation)
96+
-`.github/README.md` (documentation)
97+
-`ACTIVITY_AUTOMATION_SUMMARY.md` (this file)
98+
-`.gitignore` (allows data tracking)
99+
100+
### **Modified Files**
101+
-`.github/config/activity_config.json` (updated commit range)
102+
-`.github/workflows/auto-commit.yml` (fixed paths and logic)
103+
104+
### **Generated Files** (when script runs)
105+
-`data/logs/activity_YYYY-MM-DD.log`
106+
-`data/stats/repository_stats.json`
107+
-`data/quotes/daily_quotes.txt`
108+
109+
## 🎯 Testing Results
110+
111+
### **Local Testing**
112+
- Script executes without errors
113+
- Creates data directories and files
114+
- Generates realistic content
115+
- Commit messages work correctly
116+
117+
### **Expected GitHub Actions**
118+
- Workflow will run 12 times daily
119+
- Random execution with 40% skip rate
120+
- Creates commits when changes are made
121+
- Proper error handling and logging
122+
123+
## 🚀 Next Steps
124+
125+
1. **Commit these changes** to your repository
126+
2. **Enable GitHub Actions** in your repository settings
127+
3. **Monitor the Actions tab** to see the workflow running
128+
4. **Check your contribution graph** after a few days
129+
5. **Adjust settings** if needed (commit range, frequency, etc.)
130+
131+
## 📈 Monitoring
132+
133+
### **Check Activity**
134+
- View generated files in `data/` directory
135+
- Monitor GitHub Actions tab for workflow runs
136+
- Check commit history for automated commits
137+
138+
### **Troubleshooting**
139+
- If no commits: Check if system is enabled in config
140+
- If too many/few: Adjust skip rate or max_changes_per_run
141+
- If errors: Check workflow logs in Actions tab
142+
143+
## 🎉 Success Criteria
144+
145+
The system is now **fully functional** and will:
146+
- ✅ Generate 4-26 commits daily
147+
- ✅ Create realistic development activity
148+
- ✅ Maintain consistent GitHub contribution graph
149+
- ✅ Run automatically without manual intervention
150+
- ✅ Provide natural variance and randomness
151+
152+
**Your GitHub heatmap will now show consistent activity!** 🚀

.github/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# GitHub Activity Automation
2+
3+
This directory contains an automated GitHub activity system that generates realistic commit activity to maintain consistency in your GitHub contribution graph.
4+
5+
## How It Works
6+
7+
The system runs 12 times per day at random intervals and generates 4-26 commits daily with natural variance. It creates realistic-looking activity by:
8+
9+
1. **Daily Logs**: Updates activity logs with timestamps and random development activities
10+
2. **Statistics**: Maintains repository statistics with realistic metrics
11+
3. **Quotes**: Adds inspirational programming quotes to a daily collection
12+
13+
## Configuration
14+
15+
### `config/activity_config.json`
16+
17+
Controls the behavior of the automation:
18+
19+
```json
20+
{
21+
"enabled": true, // Turn system on/off
22+
"update_types": ["log", "stats", "quote"], // Types of updates to perform
23+
"max_changes_per_run": 3, // Max changes per execution
24+
"schedule": {
25+
"commits_per_day_min": 4, // Minimum commits per day
26+
"commits_per_day_max": 26 // Maximum commits per day
27+
},
28+
"maintenance": {
29+
"cleanup_old_logs": true, // Auto-cleanup old files
30+
"max_log_entries": 365 // Keep logs for 1 year
31+
}
32+
}
33+
```
34+
35+
## Files Generated
36+
37+
### Activity Logs (`data/logs/`)
38+
- Daily log files: `activity_YYYY-MM-DD.log`
39+
- Contains timestamps and random development activities
40+
- Examples: "Code review and optimization", "Bug fixes and improvements"
41+
42+
### Statistics (`data/stats/`)
43+
- `repository_stats.json` - Tracks daily commit metrics
44+
- Includes: commits count, lines added/removed, files changed
45+
- Auto-cleanup after 30 days
46+
47+
### Quotes (`data/quotes/`)
48+
- `daily_quotes.txt` - Collection of programming quotes
49+
- Adds one quote per execution with timestamp
50+
- 15 different inspirational programming quotes
51+
52+
## Schedule
53+
54+
The system runs at these times (UTC):
55+
- 1:00 AM, 3:30 AM, 6:15 AM, 8:45 AM
56+
- 10:30 AM, 12:15 PM, 2:45 PM, 4:30 PM
57+
- 6:15 PM, 8:45 PM, 10:30 PM, 12:15 AM
58+
59+
## Commit Messages
60+
61+
Generated commit messages include:
62+
- "Update activity log - 2024-01-15"
63+
- "Daily maintenance - Jan 15"
64+
- "Routine update 2024/01/15"
65+
- "Activity tracking update"
66+
- And 10 more variations with different date formats
67+
68+
## Randomization
69+
70+
- **40% skip rate**: Randomly skips runs for natural variance
71+
- **1-3 changes per run**: Randomly selects which updates to perform
72+
- **Random timing**: Spreads activity throughout the day
73+
- **Random content**: Different activities and quotes each time
74+
75+
## Manual Control
76+
77+
You can manually trigger the workflow:
78+
1. Go to Actions tab in your repository
79+
2. Select "Auto Commit Activity" workflow
80+
3. Click "Run workflow" button
81+
82+
## Monitoring
83+
84+
Check the generated files to monitor activity:
85+
- `data/logs/activity_YYYY-MM-DD.log` - Daily activity
86+
- `data/stats/repository_stats.json` - Commit statistics
87+
- `data/quotes/daily_quotes.txt` - Quote collection
88+
89+
## Customization
90+
91+
### Adding New Update Types
92+
93+
1. Add new function in `scripts/update_activity.py`
94+
2. Add to `update_types` in config
95+
3. Add case in main() function
96+
97+
### Changing Commit Range
98+
99+
Modify in `config/activity_config.json`:
100+
- `commits_per_day_min` and `commits_per_day_max`
101+
- Adjust `max_changes_per_run` and skip rate accordingly
102+
103+
### Custom Activities
104+
105+
Edit the `activities` list in `update_daily_log()` function to add your own development activities.
106+
107+
## Security
108+
109+
- Uses `GITHUB_TOKEN` for authentication
110+
- Runs on GitHub's hosted runners
111+
- No external dependencies or API calls
112+
- All data is stored locally in the repository
113+
114+
## Troubleshooting
115+
116+
### No Commits Generated
117+
1. Check if system is enabled in config
118+
2. Verify workflow is running in Actions tab
119+
3. Check for errors in workflow logs
120+
121+
### Too Many/Few Commits
122+
1. Adjust `max_changes_per_run` in config
123+
2. Modify skip rate in `update_activity.py`
124+
3. Change number of scheduled runs in workflow
125+
126+
### Files Not Being Committed
127+
1. Ensure `.gitignore` allows `data/` directory
128+
2. Check workflow has proper permissions
129+
3. Verify Git configuration in workflow
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"enabled": true,
3+
"update_types": ["log", "stats", "quote"],
4+
"max_changes_per_run": 3,
5+
"schedule": {
6+
"frequency": "multiple_daily",
7+
"commits_per_day_min": 4,
8+
"commits_per_day_max": 26,
9+
"description": "4-26 commits daily with random variance"
10+
},
11+
"commit_settings": {
12+
"randomize_timing": true,
13+
"randomize_content": true,
14+
"spread_throughout_day": true
15+
},
16+
"maintenance": {
17+
"cleanup_old_logs": true,
18+
"max_log_entries": 365
19+
}
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[2025-09-01 18:41:38] Dependency management
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"2025-09-01": {
3+
"commits": 1,
4+
"lines_added": 33,
5+
"lines_removed": 16,
6+
"files_changed": 4,
7+
"last_updated": "2025-09-01T18:41:38.221602"
8+
}
9+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import random
2+
from datetime import datetime
3+
4+
def generate_commit_message():
5+
message_templates = [
6+
"Update activity log - {date}",
7+
"Daily maintenance - {date}",
8+
"Routine update {date}",
9+
"Activity tracking update",
10+
"Daily system check - {date}",
11+
"Repository maintenance {date}",
12+
"Update daily metrics",
13+
"Activity log refresh - {date}",
14+
"Routine data update",
15+
"Daily activity tracking",
16+
"System update - {date}",
17+
"Maintenance routine completed",
18+
"Activity statistics update",
19+
"Daily log entry - {date}"
20+
]
21+
22+
date_formats = [
23+
datetime.now().strftime("%Y-%m-%d"),
24+
datetime.now().strftime("%b %d"),
25+
datetime.now().strftime("%Y/%m/%d"),
26+
datetime.now().strftime("%m-%d-%Y")
27+
]
28+
29+
template = random.choice(message_templates)
30+
31+
# Replace placeholders
32+
if "{date}" in template:
33+
template = template.replace("{date}", random.choice(date_formats))
34+
35+
return template
36+
37+
if __name__ == "__main__":
38+
print(generate_commit_message())

0 commit comments

Comments
 (0)