Skip to content

Commit

Permalink
rename gitlab ci files
Browse files Browse the repository at this point in the history
  • Loading branch information
mdiener21 committed Dec 8, 2023
1 parent ad7fb78 commit 1bb48e2
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions .gitlab-downstream-update-ci.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1bb48e2

Please sign in to comment.