Skip to content

Auto Commit (Reforestation) #2409

Auto Commit (Reforestation)

Auto Commit (Reforestation) #2409

Workflow file for this run

# 🌳 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"