|
1 | 1 | name: Daily Contribution |
2 | 2 |
|
3 | 3 | permissions: |
4 | | - contents: write |
| 4 | + contents: write # Required to let GITHUB_TOKEN push commits |
5 | 5 |
|
6 | 6 | on: |
7 | 7 | schedule: |
8 | | - # Runs daily at 07:00 UTC → 12:30 PM IST (safe zone) |
| 8 | + # 07:00 UTC = ~12:30 PM IST — good safe time |
9 | 9 | - cron: '0 7 * * *' |
10 | | - workflow_dispatch: |
| 10 | + workflow_dispatch: # Lets you trigger manually from the Actions tab if you want |
11 | 11 |
|
12 | 12 | jobs: |
13 | 13 | auto-contribute: |
14 | 14 | runs-on: ubuntu-latest |
15 | | - |
16 | 15 | steps: |
17 | 16 | - name: Checkout repository |
18 | | - uses: actions/checkout@v3 |
| 17 | + uses: actions/checkout@v4 # ← Updated to latest version (v4 is current in 2026) |
19 | 18 | with: |
20 | | - persist-credentials: true |
| 19 | + # No need for persist-credentials: true anymore in v4 — it handles auth better internally |
21 | 20 |
|
22 | | - # Random delay (0–2 hours) to look natural |
23 | | - - name: Random delay |
24 | | - run: | |
25 | | - echo "Sleeping for random delay..." |
26 | | - sleep $((RANDOM % 7200)) |
| 21 | + - name: Random delay (0–2 hours) to look more natural |
| 22 | + run: sleep $((RANDOM % 7200 + 1)) # +1 avoids exactly 0 sec |
27 | 23 |
|
28 | | - - name: Make daily commit (IST) |
| 24 | + - name: Make daily commit (in IST timezone) |
29 | 25 | run: | |
30 | | - export TZ="Asia/Kolkata" |
31 | | - echo "Daily update: $(date)" >> log.txt |
| 26 | + # Set timezone so date shows IST correctly in commit message |
| 27 | + export TZ=Asia/Kolkata |
32 | 28 |
|
33 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
34 | | - git config user.name "github-actions[bot]" |
| 29 | + # Append a line with current IST time — keeps file changing |
| 30 | + echo "Daily auto update: $(date '+%Y-%m-%d %H:%M:%S %Z')" >> log.txt |
| 31 | +
|
| 32 | + git config user.name "NABORAJ SARAKR" |
| 33 | + git config user.email "nishant.ns.business@gmail.com" |
35 | 34 |
|
36 | 35 | git add log.txt |
37 | | - git commit -m "chore: daily contribution" |
38 | | - git push |
| 36 | + # Only commit if there are changes (prevents empty commit errors) |
| 37 | + git diff --staged --quiet || git commit -m "chore: daily contribution $(date '+%Y-%m-%d')" |
| 38 | +
|
| 39 | + # Push — GITHUB_TOKEN has write permission from the permissions: block |
| 40 | + git push origin HEAD |
0 commit comments