mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
ci: add script to detect need of container image rebuild
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
8787036903
commit
a9014ce2ce
47
scripts/container-needs-rebuild.sh
Executable file
47
scripts/container-needs-rebuild.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Check for changes needed by the container image. Two flavours of images are
|
||||
# supported, namely 'test' and 'devel'.
|
||||
#
|
||||
# Usage: scripts/container-needs-rebuild.sh {test|devel} [git-since]
|
||||
#
|
||||
# - flavour is either 'test' or 'devel'
|
||||
# - the optional 'git-since' points to a git reference, 'origin/master' if
|
||||
# not set
|
||||
#
|
||||
# Returns 0 in case changes do not affect the container image.
|
||||
# Returns 10 in case the changes need a rebuild of the container image.
|
||||
#
|
||||
|
||||
FLAVOUR="${1}"
|
||||
|
||||
if [ "${FLAVOUR}" != 'test' ] && [ "${FLAVOUR}" != 'devel' ]
|
||||
then
|
||||
echo 'ERROR: flavour must be "test" or "devel"'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GIT_SINCE="${2}"
|
||||
if [ -z "${GIT_SINCE}" ]; then
|
||||
GIT_SINCE='origin/master'
|
||||
fi
|
||||
|
||||
MODIFIED_FILES=$(git diff --name-only "${GIT_SINCE}")
|
||||
|
||||
# files used for container image input
|
||||
# :test container
|
||||
CONTAINER_FILES="build.env scripts/Dockerfile.${FLAVOUR}"
|
||||
|
||||
for MF in ${MODIFIED_FILES}
|
||||
do
|
||||
for CF in ${CONTAINER_FILES}
|
||||
do
|
||||
if [ "${MF}" = "${CF}" ]
|
||||
then
|
||||
echo "container needs rebuild, ${CF} was modified"
|
||||
exit 10
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user