Auto Commit #2976
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Commit | |
on: | |
schedule: | |
- cron: '0 */5 * * 1-5' | |
jobs: | |
auto_commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Day of the Week | |
id: check_day | |
run: echo "::set-output name=day::$(date +%u)" # Get the day of the week (1-7, where 1 is Monday and 7 is Sunday) | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Git | |
run: | | |
git config --global user.name 'themuuln' | |
git config --global user.email 'zerone.offical@gmail.com' | |
git config pull.rebase false # Disable pull rebase to avoid potential conflicts. | |
- name: Push Random Empty Commits | |
run: | | |
cd $GITHUB_WORKSPACE | |
branch="main" | |
timestamp=$(date '+%Y-%m-%d %H:%M:%S') # Get the current timestamp. | |
git pull origin $branch --ff-only # Ensure the local branch is up to date with the remote. | |
commit_count=$((RANDOM % 1 + 4)) # Generate a random number between 1 to 2 for commit count. | |
for ((i=1; i<=commit_count; i++)); do | |
# Choose from a list of meaningful commit message prefixes | |
commit_prefix=("Fix" "Add" "Update" "Refactor" "Docs" "Test") | |
# Choose a random prefix from the list | |
random_prefix=${commit_prefix[$((RANDOM % ${#commit_prefix[@]}))]} | |
commit_message="$random_prefix: Automated commit $i of $commit_count at $timestamp by themuuln/auto-committer" | |
git commit --allow-empty -m "$commit_message" | |
done | |
git push origin $branch |