Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inject-docs
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INJECT
inject-docs
Commits
0accc344
There was an error fetching the commit references. Please try again later.
Commit
0accc344
authored
1 month ago
by
Richard Glosner
Browse files
Options
Downloads
Patches
Plain Diff
internal: add stage for automatic change propagation to main
parent
b5072ca9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+51
-0
51 additions, 0 deletions
.gitlab-ci.yml
with
51 additions
and
0 deletions
.gitlab-ci.yml
+
51
−
0
View file @
0accc344
...
...
@@ -2,11 +2,14 @@ image: python:3.10-bullseye
variables
:
GIT_SUBMODULE_STRATEGY
:
normal
PREFERRED_BRANCH
:
"
citadel"
# Change this to your actual release branch name
MAIN_BRANCH
:
"
main"
stages
:
-
setup
-
build
-
deploy
-
copy_to_main
default
:
tags
:
...
...
@@ -41,3 +44,51 @@ pages:
-
public
only
:
-
citadel
copy_to_main
:
stage
:
copy_to_main
variables
:
GIT_DEPTH
:
"
0"
script
:
-
git config --global user.email "ci@gitlab.com"
-
git config --global user.name "CI Bot"
-
git config pull.rebase
true
-
export COMMIT_NAME=$(git log --no-merges -1 --pretty=format:%s)
-
export COMMIT_HASH=$(git log --no-merges -1 --pretty=format:%h)
-
export COPY_BRANCH="COPY-${COMMIT_HASH}"
# Checkout main and create a new branch
-
git fetch origin
-
git checkout $MAIN_BRANCH
-
git pull origin $MAIN_BRANCH
-
git checkout -b $COPY_BRANCH
# Cherry-pick the commit that triggered the pipeline
-
git cherry-pick -m 1 $COMMIT_HASH || echo "Cherry-pick failed. Manual resolution needed." > cherry_pick_failed
# Push the branch
-
git push https://oauth2:${GITLAB_TOKEN}@gitlab.fi.muni.cz/${CI_PROJECT_PATH}.git HEAD:"$COPY_BRANCH"
# Create Merge Request
-
|
if [ -f cherry_pick_failed ]; then
DESCRIPTION="**Cherry-pick failed. Manual resolution needed. Commit: ${COMMIT_HASH}**."
else
DESCRIPTION="**Cherry-pick applied successfully. Commit: ${COMMIT_NAME} (hash: ${COMMIT_HASH}) applied to main.**"
fi
curl --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
--data "source_branch=$COPY_BRANCH" \
--data "target_branch=$MAIN_BRANCH" \
--data "title=[COPY]-${COMMIT_NAME}" \
--data "description=$DESCRIPTION" \
--data "remove_source_branch=true" \
--data "squash=true" \
"https://gitlab.fi.muni.cz/api/v4/projects/$CI_PROJECT_ID/merge_requests" \
> /dev/null
rules
:
-
if
:
$CI_COMMIT_BRANCH == $PREFERRED_BRANCH
when
:
manual
dependencies
:
-
build
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment