mirror of
https://github.com/netbox-community/netbox-docker.git
synced 2024-11-22 07:53:46 +01:00
Group the build output in GitHub Action
This commit is contained in:
parent
5f0b7467d1
commit
30a7aa0e9c
21
build-functions/gh-functions.sh
Normal file
21
build-functions/gh-functions.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
###
|
||||
# A regular echo, that only prints if ${GH_ACTION} is defined.
|
||||
###
|
||||
gh_echo() {
|
||||
if [ -n "${GH_ACTION}" ]; then
|
||||
echo "${@}"
|
||||
fi
|
||||
}
|
||||
|
||||
###
|
||||
# Prints the output to the file defined in ${GITHUB_ENV}.
|
||||
# Only executes if ${GH_ACTION} is defined.
|
||||
# Example Usage: gh_env "FOO_VAR=bar_value"
|
||||
###
|
||||
gh_env() {
|
||||
if [ -n "${GH_ACTION}" ]; then
|
||||
echo "${@}" >>"${GITHUB_ENV}"
|
||||
fi
|
||||
}
|
22
build.sh
22
build.sh
@ -95,6 +95,8 @@ if [ "${1}x" == "x" ] || [ "${1}" == "--help" ] || [ "${1}" == "-h" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
source ./build-functions/gh-functions.sh
|
||||
|
||||
###
|
||||
# Enabling dry-run mode
|
||||
###
|
||||
@ -105,6 +107,8 @@ else
|
||||
DRY="echo"
|
||||
fi
|
||||
|
||||
gh_echo "::group::⤵️ Fetching the NetBox source code"
|
||||
|
||||
###
|
||||
# Variables for fetching the NetBox source
|
||||
###
|
||||
@ -121,9 +125,7 @@ if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then
|
||||
REMOTE_EXISTS=$(git ls-remote --heads --tags "${URL}" "${NETBOX_BRANCH}" | wc -l)
|
||||
if [ "${REMOTE_EXISTS}" == "0" ]; then
|
||||
echo "❌ Remote branch '${NETBOX_BRANCH}' not found in '${URL}'; Nothing to do"
|
||||
if [ -n "${GH_ACTION}" ]; then
|
||||
echo "::set-output name=skipped::true"
|
||||
fi
|
||||
gh_echo "::set-output name=skipped::true"
|
||||
exit 0
|
||||
fi
|
||||
echo "🌐 Checking out '${NETBOX_BRANCH}' of NetBox from the url '${URL}' into '${NETBOX_PATH}'"
|
||||
@ -146,6 +148,9 @@ if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then
|
||||
echo "✅ Checked out NetBox"
|
||||
fi
|
||||
|
||||
gh_echo "::endgroup::"
|
||||
gh_echo "::group::🧮 Calculating Values"
|
||||
|
||||
###
|
||||
# Determining the value for DOCKERFILE
|
||||
# and checking whether it exists
|
||||
@ -221,11 +226,14 @@ DEFAULT_DOCKER_TARGETS=("main" "ldap")
|
||||
DOCKER_TARGETS=("${DOCKER_TARGET:-"${DEFAULT_DOCKER_TARGETS[@]}"}")
|
||||
echo "🏭 Building the following targets:" "${DOCKER_TARGETS[@]}"
|
||||
|
||||
gh_echo "::endgroup::"
|
||||
|
||||
###
|
||||
# Build each target
|
||||
###
|
||||
export DOCKER_BUILDKIT=${DOCKER_BUILDKIT-1}
|
||||
for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
||||
gh_echo "::group::🏗 Building the target '${DOCKER_TARGET}'"
|
||||
echo "🏗 Building the target '${DOCKER_TARGET}'"
|
||||
|
||||
###
|
||||
@ -237,10 +245,8 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
||||
fi
|
||||
TARGET_DOCKER_TAG_PROJECT="${TARGET_DOCKER_TAG}-${PROJECT_VERSION}"
|
||||
|
||||
if [ -n "${GH_ACTION}" ]; then
|
||||
echo "FINAL_DOCKER_TAG=${TARGET_DOCKER_TAG_PROJECT}" >>"$GITHUB_ENV"
|
||||
echo "::set-output name=skipped::false"
|
||||
fi
|
||||
gh_env "FINAL_DOCKER_TAG=${TARGET_DOCKER_TAG_PROJECT}"
|
||||
gh_echo "::set-output name=skipped::false"
|
||||
|
||||
###
|
||||
# composing the additional DOCKER_SHORT_TAG,
|
||||
@ -401,4 +407,6 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
||||
push_image_to_registry "${TARGET_DOCKER_LATEST_TAG_PROJECT}"
|
||||
fi
|
||||
fi
|
||||
|
||||
gh_echo "::endgroup::"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user