Skip to content

Commit

Permalink
OOB: Add script to clone application repositories (#1022)
Browse files Browse the repository at this point in the history
* Add setup script

* fix: Escape double quotes in jq expression
  • Loading branch information
joristirado authored Oct 13, 2022
1 parent 5672971 commit 5f5a8cb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash -u
#
# Performs steps to clone all monster-ui application repositories accessible for a given user

if ! [ -x "$(command -v gh)" ]; then
echo "gh is required to enumerate existing repositories." >&2
echo "Installation instructions can be found at https://cli.github.com/" >&2
exit 1
fi

readonly FILENAME_OF_REPOS="applications"
readonly REPO_SUFFIX="monster-ui-"
readonly MAX_LIMIT=1000
readonly REPONAME_PROP="name"

clone_repo() {
echo "Clonning $reponame ..."

local reponame="$1"
gh repo clone 2600hz/"${reponame}" src/apps/"${reponame#"$REPO_SUFFIX"}" >/dev//null 2>&1

echo "Done clonning $reponame"
}

main() {
gh repo list 2600hz \
--language javascript \
--no-archived \
--source \
--limit $MAX_LIMIT \
--json $REPONAME_PROP \
--jq ".[] | select(.$REPONAME_PROP | test(\"^$REPO_SUFFIX.+\")) | .$REPONAME_PROP" \
>$FILENAME_OF_REPOS

while read -r reponame; do
clone_repo "$reponame" &
done <./$FILENAME_OF_REPOS
wait
}

main

0 comments on commit 5f5a8cb

Please sign in to comment.