This commit is contained in:
Grzegorz Michalski
2026-03-02 09:47:35 +01:00
commit 2c225d68ac
715 changed files with 130067 additions and 0 deletions

74
.ci/mr_dev_to_latest.sh Normal file
View File

@@ -0,0 +1,74 @@
#!/bin/bash
REPO_URL="https://oauth2:${GL_TOKEN}@gitlab.sofa.dev/mrds/mrds_elt.git"
DEV_BRANCH="dev"
TARGET_BRANCH="latest"
WORK_DIR="mrds_elt_merge"
MERGE_BRANCH="dev_to_latest_merge"
DIRECTORIES=(
"airflow/devo_replicator"
"airflow/ods/rqsd"
"airflow/mopdb/RQSD"
"dbt"
"python/connectors/devo"
"python/devo_replicator"
"python/mrds_common"
".ci"
".gitlab-ci.yml"
".ci/mr_dev_to_latest.sh"
)
echo "Setting up working directory..."
git branch -D "$MERGE_BRANCH" 2>/dev/null || true
rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"
cd "$WORK_DIR"
echo "Cloning repository..."
git clone "$REPO_URL" .
git config --global user.email "cicd@sofa.dev"
git config --global user.name "CICD Pipeline"
echo "Creating merge branch from $TARGET_BRANCH..."
git checkout "$TARGET_BRANCH"
git checkout -b "$MERGE_BRANCH"
echo "Fetching $DEV_BRANCH branch..."
git fetch origin "$DEV_BRANCH"
echo "Selecting changes from $DEV_BRANCH for specific directories..."
CHANGES_FOUND=false
for dir in "${DIRECTORIES[@]}"; do
echo "Copying $dir from $DEV_BRANCH to $MERGE_BRANCH"
git checkout "origin/$DEV_BRANCH" -- "$dir"
done
if ! git diff --quiet "$TARGET_BRANCH"; then
git commit -am "Update selected directories from $DEV_BRANCH"
CHANGES_FOUND=true
fi
if ! git diff --quiet "$TARGET_BRANCH"; then
CHANGES_FOUND=true
fi
if [ "$CHANGES_FOUND" = true ]; then
echo "Pushing merge branch..."
git push -f -u "$REPO_URL" "$MERGE_BRANCH"
echo "Creating merge request..."
if [ -z "$GL_TOKEN" ]; then
echo "GL_TOKEN environment variable not set. Cannot create merge request."
exit 1
else
curl -X POST \
-H "PRIVATE-TOKEN: $GL_TOKEN" \
"https://gitlab.sofa.dev/api/v4/projects/${CI_PROJECT_ID}/merge_requests" \
-d "source_branch=${MERGE_BRANCH}&target_branch=${TARGET_BRANCH}&title=Requested merge of selected directories from ${DEV_BRANCH} to ${TARGET_BRANCH}&description=This MR contains selected directories from ${DEV_BRANCH} branch."
fi
else
echo "No changes found between $DEV_BRANCH and $TARGET_BRANCH for the specified directories."
echo "Skipping merge request creation."
exit 0
fi