more test
All checks were successful
Scheduled Fake Commits / create_scheduled_commits (push) Successful in 36s
All checks were successful
Scheduled Fake Commits / create_scheduled_commits (push) Successful in 36s
This commit is contained in:
parent
5efbd03d98
commit
e4cb868623
@ -1,9 +1,15 @@
|
|||||||
name: Scheduled Fake Commits
|
name: Scheduled Fake Commits
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# Trigger the workflow on a schedule.
|
||||||
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 * * * *"
|
- cron: "*/3 * * * *"
|
||||||
|
|
||||||
|
# To trigger manually for testing, you can add workflow_dispatch:
|
||||||
|
# workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create_scheduled_commits:
|
create_scheduled_commits:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -12,7 +18,12 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
# Fetch the full history to ensure pushes work correctly
|
||||||
fetch-depth: 0
|
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
|
- name: Set up Git config
|
||||||
# Configure Git user details globally for the runner
|
# Configure Git user details globally for the runner
|
||||||
@ -20,9 +31,14 @@ jobs:
|
|||||||
echo "setting up git config"
|
echo "setting up git config"
|
||||||
git config --global user.name "Gitea Actions Bot"
|
git config --global user.name "Gitea Actions Bot"
|
||||||
git config --global user.email "actions-bot@your-gitea-instance.com" # Replace with a suitable email
|
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
|
- name: Create and Push Commits
|
||||||
env:
|
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_LIST: |
|
||||||
Author One <author1@example.com>
|
Author One <author1@example.com>
|
||||||
Author Two <author2@example.com>
|
Author Two <author2@example.com>
|
||||||
@ -49,13 +65,18 @@ jobs:
|
|||||||
TARGET_BRANCH: main # The branch to commit to
|
TARGET_BRANCH: main # The branch to commit to
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
echo "reading author's list"
|
echo "starting Create and Push Commits step"
|
||||||
# Read authors into a Bash array
|
echo "AUTHOR_LIST content:"
|
||||||
IFS=$'\n' read -r -d '' -a authors <<< "$AUTHOR_LIST"
|
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
|
# Check if authors list is empty
|
||||||
if [ ${#authors[@]} -eq 0 ]; then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -71,11 +92,15 @@ jobs:
|
|||||||
author_index=$(( (i - 1) % ${#authors[@]} ))
|
author_index=$(( (i - 1) % ${#authors[@]} ))
|
||||||
current_author="${authors[$author_index]}"
|
current_author="${authors[$author_index]}"
|
||||||
|
|
||||||
|
echo "Processing author: $current_author" # Debug echo
|
||||||
|
|
||||||
# Extract name and email from the author string
|
# Extract name and email from the author string
|
||||||
# Assumes format "Name <email>"
|
# Assumes format "Name <email>"
|
||||||
author_name=$(echo "$current_author" | sed -E 's/^(.*) <.*>$/\1/')
|
author_name=$(echo "$current_author" | sed -E 's/^(.*) <.*>$/\1/')
|
||||||
author_email=$(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 ---"
|
echo "--- Creating commit $i of $COMMIT_COUNT by $author_name ---"
|
||||||
|
|
||||||
# Configure git user for this specific commit
|
# Configure git user for this specific commit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user