1111API_URI=' https://subsplash.io/api/v4'
1212WEB_URI=' https://subsplash.io'
1313
14+ # Organization or Username for the source repository
15+ # Used in the SOURCE_URL and REF_URL
16+ SOURCE_ORG=' snappages'
17+
1418# Check for a valid GitLab Personal Access Token to authenticate / authorize API calls
1519if [[ -z ${GITLAB_TOKEN} ]]; then
20+ # shellcheck disable=SC2016
1621 echo ' Error: No $GITLAB_TOKEN was found.'
1722 exit
1823fi
1924
2025# Check for valid credentials to source system; these variables are used later
2126if [[ -z ${GITHUB_USER} ]]; then
27+ # shellcheck disable=SC2016
2228 echo ' Error: $GITHUB_USER was Not found.'
2329 echo " If authentication is not required for this source SCM, edit this script and try again."
2430 exit
2531fi
2632
2733if [[ -z ${GITHUB_TOKEN} ]]; then
34+ # shellcheck disable=SC2016
2835 echo ' Error: $GITHUB_TOKEN was Not found.'
2936 echo " If authentication is not required for this source SCM, edit this script and try again."
3037 exit
@@ -44,29 +51,29 @@ GROUP_ID=233
4451# Source project URL
4552# Note: include https auth in SOURCE_URL if necessary (otherwise, forego "<USERNAME>:<PASSWORD>@")
4653# Example: https://<USERNAME>:<PASSWORD>@github.com/path/to/repo.git
47- SOURCE_URL=" https://${GITHUB_USER} :${GITHUB_TOKEN} @github.com/snappages /"
48- # SOURCE_URL="https://github.com/snappages /"
54+ SOURCE_URL=" https://${GITHUB_USER} :${GITHUB_TOKEN} @github.com/${SOURCE_ORG} /"
55+ # SOURCE_URL="https://github.com/${SOURCE_ORG} /"
4956
5057# Project Description
5158# The REF_URL should match the SOURCE_URL, without any user or token, so it can be included in
5259# the target project description. See `--form description="Cloned from ${REF_URL}${REPO}" \`
53- REF_URL=" https://github.com/snappages /"
60+ REF_URL=" https://github.com/${SOURCE_ORG} /"
5461
5562# space-delimited list of repositories available from the SOURCE_URL
56- REPOLIST=" ${@ } "
63+ REPOLIST=( " ${@ } " )
5764
58- for REPO in ${REPOLIST} ; do
65+ for REPO in " ${REPOLIST[@]} " ; do
5966
6067 echo " Cloning git repository ${REPO} to ${WEB_URI} /projects/${REPO} /"
6168
6269 IMPORT=$( curl --request POST \
63- --url $ API_URI /projects \
70+ --url " ${ API_URI} " /projects \
6471 --header ' Content-Type: multipart/form-data;' \
6572 --header " Authorization: Bearer ${GITLAB_TOKEN} " \
6673 --form description=" Cloned from ${REF_URL}${REPO} " \
6774 --form import_url=" ${SOURCE_URL}${REPO} .git" \
68- --form mirror=${MIRROR} \
69- --form namespace_id=${GROUP_ID} \
75+ --form mirror=" ${MIRROR} " \
76+ --form namespace_id=" ${GROUP_ID} " \
7077 --form path=" ${REPO} " \
7178 --form allow_merge_on_skipped_pipeline=false \
7279 --form analytics_access_level=disabled \
@@ -97,7 +104,7 @@ for REPO in ${REPOLIST}; do
97104
98105 # access properties in JSON structure of $IMPORT results
99106 echo " "
100- echo " Cloned project to $( echo ${IMPORT} | jq ' .web_url' ) "
107+ echo " Cloned project to $( echo " ${IMPORT} " | jq ' .web_url' ) "
101108 ID=$( echo " ${IMPORT} " | jq ' .id' )
102109
103110 # pause for a moment, before trying to archive the newly imported project
126133
127134# GitHub API notes:
128135# List repositories for an Org
129- curl https://$ GITHUB_USER: $ GITHUB_TOKEN @api.github.com/orgs/snappages /repos | jq ' .[].name'
136+ # curl https://"${ GITHUB_USER}":"${ GITHUB_TOKEN}" @api.github.com/orgs/${SOURCE_ORG} /repos | jq '.[].name'
130137
131- curl https://$ GITHUB_USER: $ GITHUB_TOKEN @api.github.com/snappages /
132- curl -I https://api.github.com/users/octocat/orgs
138+ # curl https://"${ GITHUB_USER}":"${ GITHUB_TOKEN}" @api.github.com/${SOURCE_ORG} /
139+ # curl -I https://api.github.com/users/octocat/orgs
133140
134- curl -H " Authorization: token OAUTH-TOKEN" https://api.github.com
141+ # curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com
0 commit comments