Skip to content

Commit c00492c

Browse files
authored
Merge pull request #579 from tobiasge/check-remote
Check if remote branch exists before checkout
2 parents 5590b32 + c4d545a commit c00492c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ NETBOX_PATH="${NETBOX_PATH-.netbox}"
118118
# Fetching the NetBox source
119119
###
120120
if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then
121+
REMOTE_EXISTS=$(git ls-remote --heads --tags "${URL}" "${NETBOX_BRANCH}" | wc -l)
122+
if [ "${REMOTE_EXISTS}" == "0" ]; then
123+
echo "❌ Remote branch '${NETBOX_BRANCH}' not found in '${URL}'; Nothing to do"
124+
if [ -n "${GH_ACTION}" ]; then
125+
echo "::set-output name=skipped::true"
126+
fi
127+
exit 0
128+
fi
121129
echo "🌐 Checking out '${NETBOX_BRANCH}' of NetBox from the url '${URL}' into '${NETBOX_PATH}'"
122130
if [ ! -d "${NETBOX_PATH}" ]; then
123131
$DRY git clone -q --depth 10 -b "${NETBOX_BRANCH}" "${URL}" "${NETBOX_PATH}"

0 commit comments

Comments
 (0)