more test
All checks were successful
Scheduled Fake Commits / create_scheduled_commits (push) Successful in 36s

This commit is contained in:
Tanishq Dubey 2025-05-10 08:24:45 -04:00
parent 5efbd03d98
commit e4cb868623
No known key found for this signature in database
GPG Key ID: CFC1931B84DFC3F9

View File

@ -1,9 +1,15 @@
name: Scheduled Fake Commits
on:
# Trigger the workflow on a schedule.
schedule:
# This expression means "run every 3 minutes". Useful for testing.
# To revert to the original 8-hour schedule, change this to '0 */8 * * *'.
- cron: "*/3 * * * *"
# To trigger manually for testing, you can add workflow_dispatch:
# workflow_dispatch:
jobs:
create_scheduled_commits:
runs-on: ubuntu-latest
@ -12,7 +18,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch the full history to ensure pushes work correctly
fetch-depth: 0
# Use a token with write access. This should be stored as a secret in your Gitea repo settings.
# The default GITEA_TOKEN might not have push permissions, so a Personal Access Token is recommended.
# Ensure you have a secret named GITEA_TOKEN in your repository settings.
token: ${{ secrets.GITEA_TOKEN }} # Replace GITEA_TOKEN with the name of your secret
- name: Set up Git config
# Configure Git user details globally for the runner
@ -20,9 +31,14 @@ jobs:
echo "setting up git config"
git config --global user.name "Gitea Actions Bot"
git config --global user.email "actions-bot@your-gitea-instance.com" # Replace with a suitable email
echo "git config setup complete"
- name: Create and Push Commits
env:
# Define your list of authors here. Each author should be on a new line,
# formatted as "Author Name <author@email.com>".
# For production, this should ideally be stored as a secret named FAKE_COMMIT_AUTHORS.
# For debugging, you can define it directly here as you have done.
AUTHOR_LIST: |
Author One <author1@example.com>
Author Two <author2@example.com>
@ -49,13 +65,18 @@ jobs:
TARGET_BRANCH: main # The branch to commit to
run: |
echo "reading author's list"
# Read authors into a Bash array
IFS=$'\n' read -r -d '' -a authors <<< "$AUTHOR_LIST"
echo "starting Create and Push Commits step"
echo "AUTHOR_LIST content:"
echo "$AUTHOR_LIST" # Echo the content of the variable for debugging
echo "reading author's list into array"
# Read authors into a Bash array using readarray
readarray -t authors <<< "$AUTHOR_LIST"
echo "finished reading author's list into array"
# Check if authors list is empty
if [ ${#authors[@]} -eq 0 ]; then
echo "Error: AUTHOR_LIST is empty. Please configure the secret."
echo "Error: AUTHOR_LIST is empty or could not be parsed into an array."
exit 1
fi
@ -71,11 +92,15 @@ jobs:
author_index=$(( (i - 1) % ${#authors[@]} ))
current_author="${authors[$author_index]}"
echo "Processing author: $current_author" # Debug echo
# Extract name and email from the author string
# Assumes format "Name <email>"
author_name=$(echo "$current_author" | sed -E 's/^(.*) <.*>$/\1/')
author_email=$(echo "$current_author" | sed -E 's/^.* <(.*)>$/\1/')
echo "Extracted name: $author_name, email: $author_email" # Debug echo
echo "--- Creating commit $i of $COMMIT_COUNT by $author_name ---"
# Configure git user for this specific commit