From 5d965ade685bcf8d98a0f8d9a297b2aa78f74e16 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Wed, 17 Aug 2022 12:41:22 +0100 Subject: [PATCH] Added gs-create-repo command Signed-off-by: Marcus Noble --- home/.bin/.utils | 4 +++ home/.bin/gs-create-repo | 74 ++++++++++++++++++++++++++++++++++++++++ install.sh | 2 +- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100755 home/.bin/gs-create-repo diff --git a/home/.bin/.utils b/home/.bin/.utils index 89b0e36..bf19c57 100644 --- a/home/.bin/.utils +++ b/home/.bin/.utils @@ -36,4 +36,8 @@ else orange() { echo $@ } + + blue() { + echo $@ + } fi diff --git a/home/.bin/gs-create-repo b/home/.bin/gs-create-repo new file mode 100755 index 0000000..f160ac5 --- /dev/null +++ b/home/.bin/gs-create-repo @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +source .utils + +TEMPLATE="giantswarm/template-app" +VISIBILITY="public" + +print_usage() { + orange "gs-create-repo - a new Giant Swarm repo" + echo " " + underline "Usage:" + echo "gs-create-repo (flags) [repo-name]" + echo " " + echo " " + underline "Options:" + echo "-h, --help show this help text" + echo "-t, --template the template repo to base the new repo on (default: ${TEMPLATE})" + echo " --visibility the visibility of the repo (default: ${VISIBILITY}" +} + + +POS_ARGS=() +while test $# -gt 0; do + case "$1" in + -t|--template) + shift + TEMPLATE=$1 + shift + ;; + -p|--private) + shift + PRIVATE="--private" + ;; + -h|--help) + print_usage + exit 0 + ;; + *) + POS_ARGS+=${1} + shift + ;; + esac +done + +case $TEMPLATE in + */*) + shift + ;; + *) + TEMPLATE="giantswarm/${TEMPLATE}" + ;; +esac + +REPOSITORY_NAME=${POS_ARGS[0]} + +echo "✨ Creating new repo $(italic ${VISIBILITY}) $(orange ${REPOSITORY_NAME}) using base template $(blue ${TEMPLATE})" +gh repo create --${VISIBILITY} --template ${TEMPLATE} giantswarm/${REPOSITORY_NAME} + +if [ -d helm/APP-NAME ]; then + mv helm/APP-NAME helm/${REPOSITORY_NAME} +fi + +devctl replace -i '{APP-NAME}' ${REPOSITORY_NAME} --ignore .git ./.** ./** + +git add -A +git commit -m "rename APP-NAME placeholder to ${REPOSITORY_NAME}" +git push + +devctl repo setup giantswarm/${REPOSITORY_NAME} \ + --allow-automerge=true --allow-mergecommit=false --allow-rebasemerge=false \ + --allow-squashmerge=true --allow-updatebranch=true --delete-branch-on-merge=true \ + --enable-issues=true --enable-projects=false --enable-wiki=false + +echo "🎉 New repo $(orange ${REPOSITORY_NAME}) created! - https://github.com/giantswarm/${REPOSITORY_NAME}" diff --git a/install.sh b/install.sh index 1f55d9c..66a2d64 100644 --- a/install.sh +++ b/install.sh @@ -30,7 +30,7 @@ BREW_TOOLS=( kubectl kubectx kustomize node procs progress ripgrep rs/tap/curlie rust starship tektoncd/tools/tektoncd-cli tldr tailscale yq hashicorp/tap/vault stats tabby vale lastpass-cli jless macchina tz vmware-tanzu/carvel/kapp viddy - homeassistant-cli act dnsmasq + homeassistant-cli act dnsmasq gh ) CARGO_TOOLS=( bottom ) NODE_TOOLS=( git-split-diffs )