-
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (53 loc) · 1.97 KB
/
autocommit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: auto-commit
on:
push:
branches:
- main
# Schedule the workflow to run every hour
schedule:
- cron: "0 * * * *"
jobs:
auto_commit:
runs-on: ubuntu-latest
steps:
- name: Check if it's time to commit
run: |
current_hour=$(date '+%H')
# Define your desired random intervals or conditions for committing
if [ $current_hour -ge 9 ] && [ $current_hour -le 18 ]; then
# Within the specified time range (e.g., from 9 AM to 6 PM)
if [ $(( RANDOM % 3 )) -eq 0 ]; then
echo "Committing..."
touch .commit_marker
else
echo "Not committing."
fi
else
# Outside the specified time range
if [ $(( RANDOM % 2 )) -eq 0 ]; then
echo "Committing..."
touch .commit_marker
else
echo "Not committing."
fi
fi
id: commit-check
- name: Commit if marked
if: steps.commit-check.outputs.commit-check == 'Committing...'
run: |
d=$(date '+%Y-%m-%dT%H:%M:%SZ')
echo $d > LAST_UPDATED
git config --local user.email "[email protected]"
git config --local user.name "WysockiD"
git add -A
arr=("commit(bot): 🐢 auto commit" "commit(bot): 🦖 auto commit" "commit(bot): 🐉 auto commit" "commit(bot): 🐸 auto commit" "commit(bot): 🦠 auto commit" "commit(bot): 🐊 auto commit" "commit(bot): 💚 auto commit" "commit(bot): 🌿 auto commit" "commit(bot): 🟩 auto commit" "commit(bot): 🌵 auto commit")
rand=$((RANDOM % ${#arr[@]}))
git commit -m "${arr[$rand]}"
touch .commit_marker
- name: GitHub Push
if: steps.commit-check.outputs.commit-check == 'Committing...'
uses: ad-m/github-push-action@master
with:
force: true
directory: "."
github_token: ${{ secrets.GITHUB_TOKEN }}