if [ -z "$remote" ] || [ -z "$token" ] || [ -z "$owner" ] || [ -z "$repo" ] || [ -z "$description" ] || [ -z "$user" ]; then echo "Не указаны обязательные параметры." && exit 1 fi if [ -z "$1" ]; then echo "Создание удалённого репозитория для текущего каталога." fi seconds=5 time_ms="$(date '+%s%3N')" if [ -z "$1" ] || [ "$1" == "delete" ]; then echo "Удаление старого репозитория." curl -i -X DELETE "https://$remote/api/v4/projects/$owner%2F$repo" \ -H "PRIVATE-TOKEN: $token" \ -H "Content-Type: application/json" -d "{\"permanently_remove\": \"true\", \"full_path\": \"$owner/$repo\"}" echo echo "Ожидание $seconds с." sleep "$seconds" fi if [ -z "$1" ] || [ "$1" == "create" ]; then echo "Создание нового репозитория пользователя." curl -i -X POST "https://$remote/api/v4/projects" \ -H "PRIVATE-TOKEN: $token" \ -H "Content-Type: application/json" -d "{\"name\": \"$repo\", \"description\": \"$description\"}" echo echo "Ожидание $seconds с." sleep "$seconds" if [ "$user" != "$owner" ]; then echo "Перемещение репозитория в группу." curl -i -X PUT "https://$remote/api/v4/projects/$user%2F$repo/transfer?namespace=$owner" \ -H "PRIVATE-TOKEN: $token" echo echo "Ожидание $seconds с." sleep "$seconds" fi fi if [ -z "$1" ] || [ "$1" == "options" ]; then if [ "$wiki" ]; then echo "Добавление страницы wiki в репозиторий." curl -i -X POST "https://$remote/api/v4/projects/$owner%2F$repo/wikis" \ -H "PRIVATE-TOKEN: $token" \ -H "Content-Type: application/json" -d "{\"content\": \"$wiki\", \"title\": \"Home\"}" echo has_wiki="enabled" else has_wiki="disabled" fi echo "Изменение свойств репозитория / отключение ненужного." curl -i -X PUT "https://$remote/api/v4/projects/$owner%2F$repo" \ -H "PRIVATE-TOKEN: $token" \ -H "Content-Type: application/json" -d "{ \"emails_disabled\": \"true\", \"issues_access_level\": \"disabled\", \"merge_requests_access_level\": \"disabled\", \"operations_access_level\": \"disabled\", \"builds_access_level\": \"disabled\", \"request_access_enabled\": \"false\", \"keep_latest_artifact\": \"false\", \"ci_forward_deployment_enabled\": \"false\", \"ci_separated_caches\": \"false\", \"ci_allow_fork_pipelines_to_run_in_parent_project\": \"false\", \"jobs_enabled\": \"false\", \"public_builds\": \"false\", \"packages_enabled\": \"false\", \"merge_requests_enabled\": \"false\", \"issues_enabled\": \"false\", \"lfs_enabled\": \"false\", \"snippets_enabled\": \"false\", \"container_registry_enabled\": \"false\", \"wiki_access_level\": \"$has_wiki\", \"container_registry_access_level\": \"disabled\", \"security_and_compliance_access_level\": \"disabled\", \"pages_access_level\": \"disabled\", \"analytics_access_level\": \"disabled\", \"forking_access_level\": \"disabled\", \"releases_access_level\": \"disabled\", \"requirements_access_level\": \"disabled\", \"environments_access_level\": \"disabled\", \"feature_flags_access_level\": \"private\", \"infrastructure_access_level\": \"private\", \"monitor_access_level\": \"disabled\", \"snippets_access_level\": \"disabled\", \"auto_devops_enabled\": \"false\", \"shared_runners_enabled\": \"false\", \"group_runners_enabled\": \"false\"}" echo echo "Добавление аватарки для репозитория." picture="$repo" if [ "$user" != "$owner" ]; then picture="website" fi curl -i -X PUT "https://$remote/api/v4/projects/$owner%2F$repo" \ -H "PRIVATE-TOKEN: $token" \ -F "avatar=@../pomodoro/pictures/$picture.jpg" echo fi if [ -z "$1" ]; then echo "Общее время выполнения: $(("$(date '+%s%3N')" - "$time_ms")) мс." fi