-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OOB: Add script to clone application repositories (#1022)
* Add setup script * fix: Escape double quotes in jq expression
- Loading branch information
1 parent
5672971
commit 5f5a8cb
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |