-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f08fe1b
commit 89d0907
Showing
1 changed file
with
30 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
#!/bin/bash | ||
echo test test | ||
# GitHub repository details | ||
|
||
# GitLab repository details | ||
REPO=$1 | ||
BRANCH=$2 | ||
TITLE=$3 | ||
BODY=$4 | ||
|
||
# Generate a random string for the branch name | ||
RANDOM_BRANCH=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1) | ||
|
||
# Create a new branch | ||
git checkout -b $RANDOM_BRANCH | ||
# Clone the repository | ||
git clone "https://gitlab.com/$REPO" temp_repo | ||
cd temp_repo | ||
|
||
# Make changes to the repository | ||
# For demonstration purposes, echo some content to a file | ||
echo "Changes" >> changes.txt | ||
# For demonstration purposes, let's edit an existing file | ||
echo "Changes" >> existing_file.txt | ||
|
||
# Add and commit changes | ||
git add . | ||
git add existing_file.txt | ||
git commit -m "Automated changes" | ||
|
||
# Push the branch to GitHub | ||
# Generate a random string for the branch name | ||
RANDOM_BRANCH=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1) | ||
|
||
# Create a new branch | ||
git checkout -b $RANDOM_BRANCH | ||
|
||
# Push the branch to GitLab | ||
git push origin $RANDOM_BRANCH | ||
|
||
# Create a pull request | ||
curl -X POST \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-d '{ "title": "'"$TITLE"'", "body": "'"$BODY"'", "head": "'"$RANDOM_BRANCH"'", "base": "'"$BRANCH"'" }' \ | ||
"https://api.github.com/repos/$REPO/pulls" | ||
# Create a merge request | ||
curl --request POST \ | ||
--header "PRIVATE-TOKEN: $GITLAB_TOKEN" \ | ||
--header "Content-Type: application/json" \ | ||
--data '{ | ||
"source_branch": "'"$RANDOM_BRANCH"'", | ||
"target_branch": "'"$BRANCH"'", | ||
"title": "'"$TITLE"'", | ||
"description": "'"$BODY"'" | ||
}' \ | ||
"https://gitlab.com/api/v4/projects/$REPO/merge_requests" | ||
|
||
# Cleanup: Remove temporary cloned repository | ||
cd .. | ||
rm -rf temp_repo |