Scripts that mimicks the Docker Hub Build environment
This commit is contained in:
parent
0a9991de96
commit
4ac8d50635
3 changed files with 51 additions and 4 deletions
6
build.sh
6
build.sh
|
@ -163,9 +163,9 @@ PROJECT_VERSION="${PROJECT_VERSION-$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]
|
|||
|
||||
# Get the Git information from the netbox directory
|
||||
if [ -d "${NETBOX_PATH}/.git" ]; then
|
||||
NETBOX_GIT_REF=$(cd ${NETBOX_PATH}; git rev-parse HEAD)
|
||||
NETBOX_GIT_BRANCH=$(cd ${NETBOX_PATH}; git rev-parse --abbrev-ref HEAD)
|
||||
NETBOX_GIT_URL=$(cd ${NETBOX_PATH}; git remote get-url origin)
|
||||
NETBOX_GIT_REF=$(cd "${NETBOX_PATH}"; git rev-parse HEAD)
|
||||
NETBOX_GIT_BRANCH=$(cd "${NETBOX_PATH}"; git rev-parse --abbrev-ref HEAD)
|
||||
NETBOX_GIT_URL=$(cd "${NETBOX_PATH}"; git remote get-url origin)
|
||||
fi
|
||||
|
||||
###
|
||||
|
|
|
@ -9,6 +9,6 @@ if [ "${SOURCE_BRANCH}" == "release" ] || [ "${DEBUG}" == "true" ]; then
|
|||
|
||||
run_build --push-only
|
||||
else
|
||||
echo "⚠️⚠️⚠️ Only pushing on 'main' branch, but current branch is '${SOURCE_BRANCH}'"
|
||||
echo "⚠️⚠️⚠️ Only pushing on 'release' branch, but current branch is '${SOURCE_BRANCH}'"
|
||||
exit 0
|
||||
fi
|
||||
|
|
47
test-hooks.sh
Executable file
47
test-hooks.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
# This helps testing and debugging the build hooks
|
||||
|
||||
# exit when a command exits with an exit code != 0
|
||||
set -e
|
||||
|
||||
prepare() {
|
||||
echo "⏱ Preparing"
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
echo "💣 Cleaning Up"
|
||||
|
||||
}
|
||||
|
||||
run_test() {
|
||||
branch="${1}"
|
||||
tag="${2}"
|
||||
echo "🏗 Testing Hook for SOURCE_BRANCH=\"${branch}\" and DOCKER_TAG=\"${tag}\""
|
||||
|
||||
export SOURCE_BRANCH="${branch}"
|
||||
SOURCE_COMMIT="$(git rev-parse HEAD)"
|
||||
export SOURCE_COMMIT
|
||||
export COMMIT_MSG=test
|
||||
export DOCKER_REPO=netboxcommunity/netbox
|
||||
export DOCKERFILE_PATH=Dockerfile
|
||||
export DOCKER_TAG="${tag}"
|
||||
export IMAGE_NAME="${DOCKER_REPO}:${DOCKER_TAG}"
|
||||
|
||||
echo "SOURCE_COMMIT=${SOURCE_COMMIT}"
|
||||
|
||||
hooks/build
|
||||
hooks/test
|
||||
DRY_RUN=on hooks/push
|
||||
}
|
||||
|
||||
echo "🐳🐳🐳 Start testing"
|
||||
|
||||
# Make sure the cleanup script is executed
|
||||
trap cleanup EXIT ERR
|
||||
|
||||
prepare
|
||||
run_test release branches
|
||||
run_test release prerelease
|
||||
run_test release release
|
||||
|
||||
echo "🐳🐳🐳 Done testing"
|
Loading…
Add table
Add a link
Reference in a new issue