From 44f2233c252602116154f3b8af32c46e0fecd007 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Sun, 19 Dec 2021 17:40:32 +0000 Subject: [PATCH] Improve gitlab repo creation Signed-off-by: Marcus Noble --- sync.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sync.sh b/sync.sh index cc14591..10a4890 100755 --- a/sync.sh +++ b/sync.sh @@ -40,6 +40,10 @@ gitlabGetRepo() { gitlabMakeRepo() { echo "Creating gitlab repo" curl -X POST --header "Content-Type: application/json" "https://gitlab.com/api/v4/projects?private_token=${GITLAB_TOKEN}" -d '{"name": "'${1}'", "visibility": "public"}' --silent 1> /dev/null + + PROJECT_ID=$(curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "https://gitlab.com/api/v4/projects/averagemarcus%2F${1}" | jq .id -r) + curl --request POST --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" --header "Content-Type: application/json" "https://gitlab.com/api/v4/projects/${PROJECT_ID}/protected_branches?name=master&push_access_level=40&merge_access_level=40&allow_force_push=true" + curl --request POST --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" --header "Content-Type: application/json" "https://gitlab.com/api/v4/projects/${PROJECT_ID}/protected_branches?name=main&push_access_level=40&merge_access_level=40&allow_force_push=true" } for REPO in ${REPOS}; do