From 1bb48e26c474d634201238ceb5635094baa91e39 Mon Sep 17 00:00:00 2001 From: mdiener21 Date: Fri, 8 Dec 2023 15:19:27 +0100 Subject: [PATCH] rename gitlab ci files --- .gitlab-ci.yml | 37 ++++++++++++++++++++++++++++++++ .gitlab-downstream-update-ci.yml | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 .gitlab-downstream-update-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..9555f00c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,37 @@ +stages: + - trigger_downstream_merge_requests + +variables: + SOURCE_BRANCH: "main" # Branch in the source repository + TARGET_BRANCH: "main" # Branch in the downstream repository + DOWNSTREAM_PROJECT_IDS: "43484495,23077745,23077517" # aau, tu, wu project ids + SOURCE_PROJECT_ID: 14108617 # ID of indrz/indrz-frontend repo the source repository + +trigger_downstream_merge_requests: + stage: trigger_downstream_merge_requests + rules: + - when: manual + script: + - apt-get update -qy + - apt-get install -y curl + - datetime=$(date '+%Y-%m-%d %H:%M:%S') + - > + for project_id in $(echo $DOWNSTREAM_PROJECT_IDS | tr "," "\n"); do + echo "Attempting to create merge request in downstream repository with project ID: $project_id"; + + # Create new merge request with datetime in title + title="Automated Merge Request - $datetime" + response=$(curl --write-out "%{http_code}" -s --request POST "https://gitlab.com/api/v4/projects/$SOURCE_PROJECT_ID/merge_requests" \ + --header "PRIVATE-TOKEN: $PRIVATE_ACCESS_TOKEN" \ + --form "source_branch=$SOURCE_BRANCH" \ + --form "target_branch=$TARGET_BRANCH" \ + --form "target_project_id=$project_id" \ + --form "title=$title" \ + --form "description=This is an automated merge request triggered by an update to the main repository.") + + if [[ "$response" -eq 201 ]] ; then + echo "Merge request created successfully in project ID: $project_id. Response: $response" + else + echo "Failed to create merge request in project ID: $project_id. Response: $response" + fi + done \ No newline at end of file diff --git a/.gitlab-downstream-update-ci.yml b/.gitlab-downstream-update-ci.yml new file mode 100644 index 00000000..9555f00c --- /dev/null +++ b/.gitlab-downstream-update-ci.yml @@ -0,0 +1,37 @@ +stages: + - trigger_downstream_merge_requests + +variables: + SOURCE_BRANCH: "main" # Branch in the source repository + TARGET_BRANCH: "main" # Branch in the downstream repository + DOWNSTREAM_PROJECT_IDS: "43484495,23077745,23077517" # aau, tu, wu project ids + SOURCE_PROJECT_ID: 14108617 # ID of indrz/indrz-frontend repo the source repository + +trigger_downstream_merge_requests: + stage: trigger_downstream_merge_requests + rules: + - when: manual + script: + - apt-get update -qy + - apt-get install -y curl + - datetime=$(date '+%Y-%m-%d %H:%M:%S') + - > + for project_id in $(echo $DOWNSTREAM_PROJECT_IDS | tr "," "\n"); do + echo "Attempting to create merge request in downstream repository with project ID: $project_id"; + + # Create new merge request with datetime in title + title="Automated Merge Request - $datetime" + response=$(curl --write-out "%{http_code}" -s --request POST "https://gitlab.com/api/v4/projects/$SOURCE_PROJECT_ID/merge_requests" \ + --header "PRIVATE-TOKEN: $PRIVATE_ACCESS_TOKEN" \ + --form "source_branch=$SOURCE_BRANCH" \ + --form "target_branch=$TARGET_BRANCH" \ + --form "target_project_id=$project_id" \ + --form "title=$title" \ + --form "description=This is an automated merge request triggered by an update to the main repository.") + + if [[ "$response" -eq 201 ]] ; then + echo "Merge request created successfully in project ID: $project_id. Response: $response" + else + echo "Failed to create merge request in project ID: $project_id. Response: $response" + fi + done \ No newline at end of file