Browse Source

update to add cleanup command

jenkins-x-bot 8 months ago
parent
commit
32483edd54
1 changed files with 12 additions and 8 deletions
  1. 12 8
      run.sh

+ 12 - 8
run.sh

@@ -45,9 +45,10 @@ delete_gitea_repo() {
     -H "Content-Type: application/json" \
     -H "Authorization: token ${GITEA_ACCESS_TOKEN}" \
     "${GITEA_PROTO}://${GITEA_HOST}:${GITEA_PORT}/api/v1/repos/${GITEA_USER}/${repo}"
-  echo
 }
 
+rm -rf workspace
+
 while read -r line; do
   repo=$(basename "${line}")
   url="${GOGS_GIT_USER}@${GOGS_HOST}:${GOGS_USER}/${repo}.git"
@@ -67,12 +68,15 @@ while read -r line; do
   url="${GITEA_GIT_USER}@${GITEA_HOST}:${GITEA_USER}/${repo}.git"
 
   cd "${line}" || exit 1
-  create_gitea_repo "${repo}"
-  #delete_gitea_repo "${repo}"
 
-  git remote rename origin gogs
-  git remote add gitea "${url}"
-  git remote -v
-  git push --mirror gitea
+  if [ "$1" = "cleanup" ]; then
+    delete_gitea_repo "${repo}"
+  else
+    create_gitea_repo "${repo}"
+    git remote rename origin gogs
+    git remote add gitea "${url}"
+    git push --mirror gitea
+  fi
+
   cd ../.. || exit 1
-done < <(find . -mindepth 2 -maxdepth 2 -type d -not -name workspace;)
+done < <(find workspace -mindepth 1 -maxdepth 1 -type d;)