|
| 1 | +name: My Activity Bot |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # --- WEEKDAY SCHEDULE (IST / UTC) --- |
| 6 | + # Monday-Friday: Work mode |
| 7 | + - cron: '0 2 * * 1-5' # 07:30 AM IST |
| 8 | + - cron: '0 8 * * 1-5' # 01:30 PM IST |
| 9 | + - cron: '0 14 * * 1-5' # 07:30 PM IST |
| 10 | + |
| 11 | + # --- WEEKEND SCHEDULE (IST / UTC) --- |
| 12 | + # Saturday-Sunday: Relaxed mode (starts later) |
| 13 | + - cron: '0 3 * * 0,6' # 08:30 AM IST |
| 14 | + - cron: '0 9 * * 0,6' # 02:30 PM IST |
| 15 | + - cron: '0 15 * * 0,6' # 08:30 PM IST |
| 16 | + |
| 17 | + # Manual trigger for testing |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +jobs: |
| 21 | + auto_commit: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 # Fetch full history for git stats |
| 31 | + |
| 32 | + - name: Generate Activity |
| 33 | + run: | |
| 34 | + # Create activity directory if it doesn't exist |
| 35 | + mkdir -p .activity |
| 36 | + |
| 37 | + # Generate a unique activity file with timestamp |
| 38 | + TIMESTAMP=$(date '+%Y-%m-%d_%H-%M-%S') |
| 39 | + ACTIVITY_FILE=".activity/log_${TIMESTAMP}.txt" |
| 40 | + |
| 41 | + # Add varied content to make commits more substantial |
| 42 | + echo "=== Activity Log ===" > $ACTIVITY_FILE |
| 43 | + echo "Timestamp: $(date '+%Y-%m-%d %H:%M:%S %Z')" >> $ACTIVITY_FILE |
| 44 | + echo "Day: $(date '+%A')" >> $ACTIVITY_FILE |
| 45 | + echo "Week: $(date '+%U')" >> $ACTIVITY_FILE |
| 46 | + echo "Commit #: $(git rev-list --count HEAD 2>/dev/null || echo 0)" >> $ACTIVITY_FILE |
| 47 | + echo "" >> $ACTIVITY_FILE |
| 48 | + echo "Status: Active β" >> $ACTIVITY_FILE |
| 49 | + echo "Random Hash: $RANDOM" >> $ACTIVITY_FILE |
| 50 | + |
| 51 | + # Also update a main persistent log file |
| 52 | + echo "[$(date '+%Y-%m-%d %H:%M:%S')] Automated activity update" >> .activity/main_log.txt |
| 53 | + |
| 54 | + - name: Random Delay for Natural Timing |
| 55 | + run: | |
| 56 | + # Add random delay (0-8 minutes) to make commits appear more human-like |
| 57 | + # This prevents all commits from happening at exactly XX:00:00 |
| 58 | + DELAY=$((RANDOM % 480)) |
| 59 | + echo "β±οΈ Adding natural delay of $DELAY seconds..." |
| 60 | + sleep $DELAY |
| 61 | + |
| 62 | + - name: Commit Changes |
| 63 | + run: | |
| 64 | + # --- CRITICAL CONFIGURATION --- |
| 65 | + # Using your real email so GitHub credits YOU with the contribution |
| 66 | + git config --global user.name "lovnishverma" |
| 67 | + git config --global user.email "[email protected]" |
| 68 | + |
| 69 | + git add .activity/ |
| 70 | + |
| 71 | + # Varied commit messages for more natural activity |
| 72 | + MESSAGES=( |
| 73 | + "π Daily activity update" |
| 74 | + "π Automated sync" |
| 75 | + "β¨ Activity log updated" |
| 76 | + "π€ Bot: keeping things active" |
| 77 | + "π Regular maintenance" |
| 78 | + "β‘ Activity checkpoint" |
| 79 | + "π― Daily contribution" |
| 80 | + "π Minor fix in logs" |
| 81 | + "π Performance update" |
| 82 | + "πΎ Data sync complete" |
| 83 | + "π§ System maintenance" |
| 84 | + "π Stats updated" |
| 85 | + ) |
| 86 | + |
| 87 | + # Select a random message |
| 88 | + RANDOM_MSG=${MESSAGES[$RANDOM % ${#MESSAGES[@]}]} |
| 89 | + |
| 90 | + # Only commit if there are changes |
| 91 | + if git diff --staged --quiet; then |
| 92 | + echo "No changes to commit" |
| 93 | + else |
| 94 | + git commit -m "$RANDOM_MSG" -m "Generated at: $(date '+%Y-%m-%d %H:%M:%S %Z')" |
| 95 | + git push |
| 96 | + fi |
| 97 | + |
| 98 | + - name: Cleanup Old Logs |
| 99 | + run: | |
| 100 | + # Keep only last 30 days of individual logs to avoid repo bloat |
| 101 | + find .activity -name "log_*.txt" -type f -mtime +30 -delete |
| 102 | + |
| 103 | + # Commit cleanup if files were deleted |
| 104 | + if ! git diff --quiet .activity/; then |
| 105 | + # Re-apply config to be safe |
| 106 | + git config --global user.name "lovnishverma" |
| 107 | + git config --global user.email "[email protected]" |
| 108 | + |
| 109 | + git add .activity/ |
| 110 | + git commit -m "π§Ή Cleanup: removed old activity logs" |
| 111 | + git push |
| 112 | + fi |
0 commit comments