Use jq to parse GitHub release API output in get-starter-kit.sh
This commit is contained in:
parent
eb0066e3e3
commit
1957d56ac2
1 changed files with 7 additions and 9 deletions
|
@ -17,18 +17,16 @@ set -o errexit -o nounset -o pipefail
|
||||||
STARTER_KIT_VERSION="${1:-latest}"
|
STARTER_KIT_VERSION="${1:-latest}"
|
||||||
STARTER_KIT_PROJECT="${2:-Orange-OpenSource/AWSTerraformStarterKit}"
|
STARTER_KIT_PROJECT="${2:-Orange-OpenSource/AWSTerraformStarterKit}"
|
||||||
|
|
||||||
if [ "$STARTER_KIT_VERSION" == "latest" ]; then
|
STARTER_KIT_FORMAT="zip"
|
||||||
|
STARTER_KIT_URL="https://github.com/${STARTER_KIT_PROJECT}"
|
||||||
|
|
||||||
LOCATION=$(curl -s "https://api.github.com/repos/${STARTER_KIT_PROJECT}/releases/latest \
|
if [ "$STARTER_KIT_VERSION" == "latest" ]; then
|
||||||
| grep "tag_name" \
|
STARTER_KIT_VERSION=$(curl -s "https://api.github.com/repos/${STARTER_KIT_PROJECT}/releases/latest" | jq -r ".tag_name")
|
||||||
| awk '{print "https://github.com/${STARTER_KIT_PROJECT}/archive/" substr($2, 2, length($2)-3) ".zip"}') \
|
|
||||||
; curl -L -o /tmp/archive.zip "$LOCATION"
|
|
||||||
else
|
|
||||||
curl -L\
|
|
||||||
"https://github.com/${STARTER_KIT_PROJECT}/archive/refs/tags/${STARTER_KIT_VERSION}.zip" \
|
|
||||||
-o /tmp/archive.zip
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
STARTER_KIT_LOCATION="${STARTER_KIT_URL}/archive/refs/tags/${STARTER_KIT_VERSION}.${STARTER_KIT_FORMAT}"
|
||||||
|
curl --fail -L "${STARTER_KIT_LOCATION}" -o /tmp/archive.zip
|
||||||
|
|
||||||
unzip /tmp/archive.zip -d .
|
unzip /tmp/archive.zip -d .
|
||||||
cp -r AWSTerraformStarterKit-*/. .
|
cp -r AWSTerraformStarterKit-*/. .
|
||||||
rm -rf AWSTerraformStarterKit-*
|
rm -rf AWSTerraformStarterKit-*
|
||||||
|
|
Loading…
Reference in a new issue