name: Scheduled Fake Commits on: schedule: - cron: "*/3 * * * *" jobs: create_scheduled_commits: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Git config # Configure Git user details globally for the runner run: | 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 - name: Create and Push Commits env: AUTHOR_LIST: | Author One Author Two Author Three Author Four Author Five Author Six Author Seven Author Eight Author Nine Author Ten DWSAuthor One DWSAuthor Two DWSAuthor Three DWSAuthor Four DWSAuthor Five DWSAuthor Six DWSAuthor Seven DWSAuthor Eight DWSAuthor Nine DWSAuthor Ten COMMIT_COUNT: 2 # Number of commits to create SLEEP_SECONDS: 15 # Delay between commits in seconds 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" # Check if authors list is empty if [ ${#authors[@]} -eq 0 ]; then echo "Error: AUTHOR_LIST is empty. Please configure the secret." exit 1 fi echo "Starting commit creation process..." echo "Authors available: ${#authors[@]}" echo "Commits to create: $COMMIT_COUNT" echo "Delay between commits: $SLEEP_SECONDS seconds" echo "Target branch: $TARGET_BRANCH" # Loop to create the specified number of commits for i in $(seq 1 $COMMIT_COUNT); do # Calculate the index for the current author, cycling through the list author_index=$(( (i - 1) % ${#authors[@]} )) current_author="${authors[$author_index]}" # Extract name and email from the author string # Assumes format "Name " author_name=$(echo "$current_author" | sed -E 's/^(.*) <.*>$/\1/') author_email=$(echo "$current_author" | sed -E 's/^.* <(.*)>$/\1/') echo "--- Creating commit $i of $COMMIT_COUNT by $author_name ---" # Configure git user for this specific commit git config user.name "$author_name" git config user.email "$author_email" # Create a dummy change: append current timestamp and author to a file # This ensures there's always something to commit echo "$(date): Commit $i by $author_name" >> fake_commit_log.txt # Stage the changes git add fake_commit_log.txt # Commit the changes git commit -m "Automated commit $i by $author_name" # Push the commit to the target branch # Use --set-upstream origin $TARGET_BRANCH on the first push if needed echo "Pushing commit..." git push origin HEAD:$TARGET_BRANCH echo "Commit $i pushed successfully." # Wait for the specified delay before the next commit, unless it's the last one if [ $i -lt $COMMIT_COUNT ]; then echo "Waiting for $SLEEP_SECONDS seconds..." sleep $SLEEP_SECONDS fi done echo "Finished creating $COMMIT_COUNT commits."