2018-01-30 11:45:53 +01:00
|
|
|
#!/bin/bash
|
2019-12-10 21:44:11 +01:00
|
|
|
# Builds develop, develop-* and master branches of Netbox
|
2018-01-30 11:45:53 +01:00
|
|
|
|
2018-04-10 10:58:31 +02:00
|
|
|
echo "▶️ $0 $*"
|
|
|
|
|
2019-10-10 12:42:10 +02:00
|
|
|
###
|
|
|
|
# Checking for the presence of GITHUB_OAUTH_CLIENT_ID
|
|
|
|
# and GITHUB_OAUTH_CLIENT_SECRET
|
|
|
|
###
|
2019-02-01 09:58:07 +01:00
|
|
|
if [ -n "${GITHUB_OAUTH_CLIENT_ID}" ] && [ -n "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
|
2018-08-28 18:21:08 +02:00
|
|
|
echo "🗝 Performing authenticated Github API calls."
|
|
|
|
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
|
|
|
|
else
|
|
|
|
echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!"
|
|
|
|
GITHUB_OAUTH_PARAMS=""
|
|
|
|
fi
|
|
|
|
|
2019-10-10 12:42:10 +02:00
|
|
|
###
|
|
|
|
# Calling Github to get the all branches
|
|
|
|
###
|
2019-07-02 21:32:58 +02:00
|
|
|
ORIGINAL_GITHUB_REPO="${SRC_ORG-netbox-community}/${SRC_REPO-netbox}"
|
2018-01-30 11:45:53 +01:00
|
|
|
GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}"
|
2018-08-28 18:21:08 +02:00
|
|
|
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches?${GITHUB_OAUTH_PARAMS}"
|
2018-01-30 11:45:53 +01:00
|
|
|
|
2019-10-10 12:42:10 +02:00
|
|
|
# Composing the JQ commans to extract the most recent version number
|
2020-04-08 21:38:50 +02:00
|
|
|
JQ_NEXT='map(.name) | .[] | scan("^[^v].+") | match("^(develop-).*") | .string'
|
2019-10-10 12:42:10 +02:00
|
|
|
|
2018-03-05 14:29:24 +01:00
|
|
|
CURL="curl -sS"
|
2018-01-30 11:45:53 +01:00
|
|
|
|
2019-10-10 12:42:10 +02:00
|
|
|
# Querying the Github API to fetch all branches
|
2020-04-08 21:38:50 +02:00
|
|
|
NEXT=$($CURL "${URL_RELEASES}" | jq -r "$JQ_NEXT")
|
2019-10-10 12:42:10 +02:00
|
|
|
|
2020-04-13 21:23:50 +02:00
|
|
|
if [ -n "$NEXT" ]; then
|
|
|
|
# shellcheck disable=SC2068
|
|
|
|
./build.sh "${NEXT}" $@
|
|
|
|
else
|
|
|
|
echo "No branch matching 'develop-*' found"
|
|
|
|
echo "::set-output name=skipped::true"
|
|
|
|
fi
|