-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (77 loc) · 2.71 KB
/
auto-commit.yaml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# 🌳 Reboisasii
# GitHub Actions auto commit task
name: "Auto Commit (Reforestation)"
on:
# workflow_dispatch:
push:
branches:
- "main"
schedule:
# Total 12x commit each day
# 2x complete song commit
#
# [hour]: song_index
# 7: 5 ,14: 5
# 8: 4 ,19: 4
# 9: 3 ,20: 3
# 10: 2 ,21: 2
# 11: 1 ,22: 1
# 13: 0 ,23: 0
- cron: "0 7,8,9,10,11,13,14,19,20,21,22,23 * * *"
jobs:
AUTO_COMMIT:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: "Set Global Directory"
run: "git config --global --add safe.directory /github/workspace"
- name: "Run Bash Script to Modify Last Update"
run: |
# Give execution permission
chmod +x readme-update_date.sh
# Run the script
./readme-update_date.sh
- name: "Commit Changes"
run: |
git config --local user.email "[email protected]"
git config --local user.name "ranggabs"
COMMIT_MESSAGE=""
TODAY=$(TZ="Asia/Jakarta" date +%A)
###################################
# Commit message when it's Sunday #
###################################
if [[ $TODAY == "Sunday" ]]; then
EMOJIS=(
'🌳' '🌲' '🏡' '🍏' '🎉'
'✨' '🍃' '🍀' '🌿' '🥬'
)
EMOJIS_COUNT=${#EMOJIS[@]}
RANDOM_EMOJI_INDEX=$((RANDOM % EMOJIS_COUNT))
EMOJI=${EMOJIS[$RANDOM_EMOJI_INDEX]}
COMMIT_MESSAGE="$EMOJI Reforestation"
#######################################
# Commit message when it's not Sunday #
#######################################
else
# Import script
source LYRICS.sh
# Pick song line for current commit message
CURRENT_SONG_LINE_INDEX=$(cat next_song_line_index.txt)
SONG_LINE=${LYRICS[$CURRENT_SONG_LINE_INDEX]}
# Give execution permission
chmod +x update_next_song_line_index.sh
# Run the script
./update_next_song_line_index.sh
COMMIT_MESSAGE="$SONG_LINE"
fi
git add --all
git commit -m "$COMMIT_MESSAGE"
- name: "Push Changes"
uses: "ad-m/[email protected]"
with:
directory: "."
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "main"