mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 20:52:12 -05:00
commit
9d5d792af8
7 changed files with 157 additions and 128 deletions
|
@ -54,8 +54,8 @@ ValidateInput()
|
|||
# Validate GITHUB_WORKSPACE #
|
||||
############################
|
||||
if [ -z "$GITHUB_WORKSPACE" ]; then
|
||||
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!"
|
||||
echo "ERROR:[$GITHUB_WORKSPACE]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
|
||||
|
@ -66,15 +66,15 @@ ValidateInput()
|
|||
#######################
|
||||
if [ -z "$IMAGE_REPO" ]; then
|
||||
# No repo was pulled
|
||||
echo "ERROR! Failed to get [IMAGE_REPO]!"
|
||||
echo "ERROR:[$IMAGE_REPO]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]${NC}"
|
||||
exit 1
|
||||
elif [[ "$IMAGE_REPO" == "github/super-linter" ]]; then
|
||||
# Found our main repo
|
||||
echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]"
|
||||
else
|
||||
# This is a fork and we cant pull vars or any info
|
||||
echo "WARN! No image to cleanup as this is a forked branch, and not being built with current automation!"
|
||||
echo -e "${NC}${F[Y]}WARN!${NC} No image to cleanup as this is a forked branch, and not being built with current automation!${NC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -82,8 +82,8 @@ ValidateInput()
|
|||
# Validate IMAGE_VERSION #
|
||||
##########################
|
||||
if [ -z "$IMAGE_VERSION" ]; then
|
||||
echo "ERROR! Failed to get [IMAGE_VERSION]!"
|
||||
echo "ERROR:[$IMAGE_VERSION]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_VERSION]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]"
|
||||
|
@ -93,8 +93,8 @@ ValidateInput()
|
|||
# Validate DOCKER_USERNAME #
|
||||
############################
|
||||
if [ -z "$DOCKER_USERNAME" ]; then
|
||||
echo "ERROR! Failed to get [DOCKER_USERNAME]!"
|
||||
echo "ERROR:[$DOCKER_USERNAME]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]"
|
||||
|
@ -104,8 +104,8 @@ ValidateInput()
|
|||
# Validate DOCKER_PASSWORD #
|
||||
############################
|
||||
if [ -z "$DOCKER_PASSWORD" ]; then
|
||||
echo "ERROR! Failed to get [DOCKER_PASSWORD]!"
|
||||
echo "ERROR:[$DOCKER_PASSWORD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
||||
|
@ -157,8 +157,8 @@ LoginToDocker()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to authenticate to DockerHub!"
|
||||
echo "ERROR:[$LOGIN_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
|
@ -197,8 +197,8 @@ RemoveImage()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to gain token from DockerHub!"
|
||||
echo "ERROR:[$TOKEN]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$TOKEN]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
|
@ -222,8 +222,8 @@ RemoveImage()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to remove tag from DockerHub!"
|
||||
echo "ERROR:[$REMOVE_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REMOVE_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
|
|
|
@ -53,8 +53,8 @@ CheckGHEPid()
|
|||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
echo "ERROR! Failed to sleep!"
|
||||
echo "ERROR:[$SLEEP_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]${NC}"
|
||||
echo "Will try to call apply as last effort..."
|
||||
####################################
|
||||
# Call config apply as last effort #
|
||||
|
@ -117,8 +117,8 @@ CheckGHEProcess()
|
|||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
echo "ERROR! Failed to sleep!"
|
||||
echo "ERROR:[$SLEEP_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]${NC}"
|
||||
echo "Will try to call apply as last effort..."
|
||||
####################################
|
||||
# Call config apply as last effort #
|
||||
|
@ -161,12 +161,12 @@ RunConfigApply()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Errors
|
||||
echo "ERROR! Failed to run config apply command!"
|
||||
echo "ERROR:[$APPLY_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$APPLY_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# Success
|
||||
echo "Successfully ran $GHE_APPLY_COMMAND"
|
||||
echo -e "${NC}${F[B]}Successfully ran ${F[C]}$GHE_APPLY_COMMAND${NC}"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
|
|
|
@ -60,22 +60,22 @@ ValidateInput()
|
|||
# Validate GITHUB_WORKSPACE #
|
||||
#############################
|
||||
if [ -z "$GITHUB_WORKSPACE" ]; then
|
||||
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!"
|
||||
echo "ERROR:[$GITHUB_WORKSPACE]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[$GITHUB_WORKSPACE]${NC}"
|
||||
fi
|
||||
|
||||
#####################
|
||||
# Validate REGISTRY #
|
||||
#####################
|
||||
if [ -z "$REGISTRY" ]; then
|
||||
echo "ERROR! Failed to get [REGISTRY]!"
|
||||
echo "ERROR:[$REGISTRY]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REGISTRY]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[REGISTRY], value:[$REGISTRY]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[$REGISTRY]${NC}"
|
||||
fi
|
||||
|
||||
#####################################################
|
||||
|
@ -86,22 +86,22 @@ ValidateInput()
|
|||
# Validate GPR_USERNAME #
|
||||
#########################
|
||||
if [ -z "$GPR_USERNAME" ]; then
|
||||
echo "ERROR! Failed to get [GPR_USERNAME]!"
|
||||
echo "ERROR:[$GPR_USERNAME]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_USERNAME]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GPR_USERNAME], value:[$GPR_USERNAME]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[$GPR_USERNAME]${NC}"
|
||||
fi
|
||||
|
||||
######################
|
||||
# Validate GPR_TOKEN #
|
||||
######################
|
||||
if [ -z "$GPR_TOKEN" ]; then
|
||||
echo "ERROR! Failed to get [GPR_TOKEN]!"
|
||||
echo "ERROR:[$GPR_TOKEN]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_TOKEN]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GPR_TOKEN], value:[********]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}"
|
||||
fi
|
||||
########################################
|
||||
# See if we need values for Ducker hub #
|
||||
|
@ -111,28 +111,28 @@ ValidateInput()
|
|||
# Validate DOCKER_USERNAME #
|
||||
############################
|
||||
if [ -z "$DOCKER_USERNAME" ]; then
|
||||
echo "ERROR! Failed to get [DOCKER_USERNAME]!"
|
||||
echo "ERROR:[$DOCKER_USERNAME]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[$DOCKER_USERNAME]${NC}"
|
||||
fi
|
||||
|
||||
############################
|
||||
# Validate DOCKER_PASSWORD #
|
||||
############################
|
||||
if [ -z "$DOCKER_PASSWORD" ]; then
|
||||
echo "ERROR! Failed to get [DOCKER_PASSWORD]!"
|
||||
echo "ERROR:[$DOCKER_PASSWORD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}"
|
||||
fi
|
||||
###########################################
|
||||
# We were not passed a registry to update #
|
||||
###########################################
|
||||
else
|
||||
echo "ERROR! Failed to find a valid registry!"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find a valid registry!${NC}"
|
||||
echo "Registry:[$REGISTRY]"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -142,11 +142,11 @@ ValidateInput()
|
|||
# Validate IMAGE_REPO #
|
||||
#######################
|
||||
if [ -z "$IMAGE_REPO" ]; then
|
||||
echo "ERROR! Failed to get [IMAGE_REPO]!"
|
||||
echo "ERROR:[$IMAGE_REPO]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[$IMAGE_REPO]${NC}"
|
||||
###############################################
|
||||
# Need to see if GPR registry and update name #
|
||||
###############################################
|
||||
|
@ -161,7 +161,7 @@ ValidateInput()
|
|||
# Validate IMAGE_VERSION #
|
||||
##########################
|
||||
if [ -z "$IMAGE_VERSION" ]; then
|
||||
echo "WARN! Failed to get [IMAGE_VERSION]!"
|
||||
echo -e "${NC}${F[Y]}WARN!${NC} Failed to get [IMAGE_VERSION]!${NC}"
|
||||
echo "Pulling from Branch Name..."
|
||||
##############################
|
||||
# Get the name of the branch #
|
||||
|
@ -177,8 +177,8 @@ ValidateInput()
|
|||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
echo "ERROR! Failed to get branch name!"
|
||||
echo "ERROR:[$BRANCH_NAME]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$BRANCH_NAME]${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -193,7 +193,7 @@ ValidateInput()
|
|||
IMAGE_VERSION="$BRANCH_NAME"
|
||||
echo "Tag:[$IMAGE_VERSION]"
|
||||
else
|
||||
echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[$IMAGE_VERSION]${NC}"
|
||||
fi
|
||||
|
||||
##################################
|
||||
|
@ -224,11 +224,11 @@ ValidateInput()
|
|||
# Validate DOCKERFILE_PATH #
|
||||
############################
|
||||
if [ -z "$DOCKERFILE_PATH" ]; then
|
||||
echo "ERROR! Failed to get [DOCKERFILE_PATH]!"
|
||||
echo "ERROR:[$DOCKERFILE_PATH]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKERFILE_PATH]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[DOCKERFILE_PATH], value:[$DOCKERFILE_PATH]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[$DOCKERFILE_PATH]${NC}"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
|
@ -267,12 +267,12 @@ Authenticate()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to authenticate to $NAME!"
|
||||
echo "ERROR:[$LOGIN_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to $NAME!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
echo "Successfully authenticated to $NAME!"
|
||||
echo -e "${NC}${F[B]}Successfully authenticated to ${F[C]}$NAME${F[B]}!${NC}"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
|
@ -293,7 +293,7 @@ BuildImage()
|
|||
################################
|
||||
if [ ! -f "$DOCKERFILE_PATH" ]; then
|
||||
# No file found
|
||||
echo "ERROR! failed to find Dockerfile at:[$DOCKERFILE_PATH]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[$DOCKERFILE_PATH]${NC}"
|
||||
echo "Please make sure you give full path!"
|
||||
echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory"
|
||||
exit 1
|
||||
|
@ -314,11 +314,11 @@ BuildImage()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! failed to [build] Dockerfile!"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
echo "Successfully Built image!"
|
||||
echo -e "${NC}${F[B]}Successfully Built image!${NC}"
|
||||
fi
|
||||
|
||||
########################################################
|
||||
|
@ -338,11 +338,11 @@ BuildImage()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! failed to [tag] Dockerfile!"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
echo "Successfully tagged image!"
|
||||
echo -e "${NC}${F[B]}Successfully tagged image!${NC}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -374,11 +374,11 @@ UploadImage()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! failed to [upload] Dockerfile!"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
echo "Successfully Uploaded Docker image:[$IMAGE_VERSION] to $REGISTRY!"
|
||||
echo -e "${NC}${F[B]}Successfully Uploaded Docker image:${F[W]}[$IMAGE_VERSION]${F[B]} to ${F[C]}$REGISTRY${F[B]}!${NC}"
|
||||
fi
|
||||
|
||||
#########################
|
||||
|
@ -397,8 +397,8 @@ UploadImage()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to get information about built Image!"
|
||||
echo "ERROR:[$GET_INFO_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GET_INFO_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
################
|
||||
|
@ -440,11 +440,11 @@ UploadImage()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! failed to [upload] MAJOR_TAG:[$MAJOR_TAG] Dockerfile!"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[$MAJOR_TAG] Dockerfile!${NC}"
|
||||
exit 1
|
||||
else
|
||||
# SUCCESS
|
||||
echo "Successfully Uploaded TAGOR_TAG:[$MAJOR_TAG] Docker image to $REGISTRY!"
|
||||
echo -e "${NC}${F[B]}Successfully Uploaded TAGOR_TAG:${F[W]}[$MAJOR_TAG]${F[B]} Docker image to ${F[C]}$REGISTRY${F[B]}!${NC}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ else
|
|||
#########
|
||||
# ERROR #
|
||||
#########
|
||||
echo "ERROR! Registry not set correctly!"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!${NC}"
|
||||
echo "Registry:[$REGISTRY]"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -39,7 +39,7 @@ function BuildFileList()
|
|||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Error
|
||||
echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!"
|
||||
echo "ERROR:[$SWITCH_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH_CMD]${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -67,8 +67,8 @@ function BuildFileList()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Error
|
||||
echo "ERROR! Failed to gain a list of all files changed!"
|
||||
echo "ERROR:[${RAW_FILE_ARRAY[*]}]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -375,7 +375,7 @@ function BuildFileList()
|
|||
#######################
|
||||
# It is a bash script #
|
||||
#######################
|
||||
echo "WARN! Found bash script without extension:[.sh]"
|
||||
echo -e "${NC}${F[Y]}WARN!${NC} Found bash script without extension:[.sh]${NC}"
|
||||
echo "Please update file with proper extensions."
|
||||
################################
|
||||
# Append the file to the array #
|
||||
|
@ -389,7 +389,7 @@ function BuildFileList()
|
|||
#######################
|
||||
# It is a Ruby script #
|
||||
#######################
|
||||
echo "WARN! Found ruby script without extension:[.rb]"
|
||||
echo -e "${NC}${F[Y]}WARN!${NC} Found ruby script without extension:[.rb]${NC}"
|
||||
echo "Please update file with proper extensions."
|
||||
################################
|
||||
# Append the file to the array #
|
||||
|
@ -403,7 +403,7 @@ function BuildFileList()
|
|||
############################
|
||||
# Extension was not found! #
|
||||
############################
|
||||
echo " - WARN! Failed to get filetype for:[$FILE]!"
|
||||
echo -e "${NC}${F[Y]} - WARN!${NC} Failed to get filetype for:[$FILE]!${NC}"
|
||||
##########################################################
|
||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
|
@ -430,7 +430,7 @@ function BuildFileList()
|
|||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Error
|
||||
echo "Failed to switch back to branch!"
|
||||
echo "ERROR:[$SWITCH2_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH2_CMD]${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -439,5 +439,5 @@ function BuildFileList()
|
|||
################
|
||||
echo ""
|
||||
echo "----------------------------------------------"
|
||||
echo "Successfully gathered list of files..."
|
||||
echo -e "${NC}${F[B]}Successfully gathered list of files...${NC}"
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
# Source Function Files #
|
||||
#########################
|
||||
# shellcheck source=/dev/null
|
||||
source /action/lib/termColors.sh # Source the function script(s)
|
||||
# shellcheck source=/dev/null
|
||||
source /action/lib/buildFileList.sh # Source the function script(s)
|
||||
# shellcheck source=/dev/null
|
||||
source /action/lib/validation.sh # Source the function script(s)
|
||||
|
@ -277,7 +279,7 @@ GetLinterVersions()
|
|||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then
|
||||
echo "WARN! Failed to get version info for:[$LINTER]"
|
||||
echo -e "${NC}${F[Y]}WARN!${NC} Failed to get version info for:[$LINTER]${NC}"
|
||||
echo "---------------------------------------------"
|
||||
else
|
||||
##########################
|
||||
|
@ -363,8 +365,8 @@ GetStandardRules()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# ERROR
|
||||
echo "ERROR! Failed to gain list of ENV vars to load!"
|
||||
echo "ERROR:[${GET_ENV_ARRAY[*]}]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -565,33 +567,33 @@ GetGitHubVars()
|
|||
# Validate we have a value #
|
||||
############################
|
||||
if [ -z "$GITHUB_SHA" ]; then
|
||||
echo "ERROR! Failed to get [GITHUB_SHA]!"
|
||||
echo "ERROR:[$GITHUB_SHA]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_SHA]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GITHUB_SHA], value:[$GITHUB_SHA]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[$GITHUB_SHA]${NC}"
|
||||
fi
|
||||
|
||||
############################
|
||||
# Validate we have a value #
|
||||
############################
|
||||
if [ -z "$GITHUB_WORKSPACE" ]; then
|
||||
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!"
|
||||
echo "ERROR:[$GITHUB_WORKSPACE]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[$GITHUB_WORKSPACE]${NC}"
|
||||
fi
|
||||
|
||||
############################
|
||||
# Validate we have a value #
|
||||
############################
|
||||
if [ -z "$GITHUB_EVENT_PATH" ]; then
|
||||
echo "ERROR! Failed to get [GITHUB_EVENT_PATH]!"
|
||||
echo "ERROR:[$GITHUB_EVENT_PATH]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_EVENT_PATH]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GITHUB_EVENT_PATH], value:[$GITHUB_EVENT_PATH]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[$GITHUB_EVENT_PATH]${F[B]}${NC}"
|
||||
fi
|
||||
|
||||
##################################################
|
||||
|
@ -607,11 +609,11 @@ GetGitHubVars()
|
|||
# Validate we have a value #
|
||||
############################
|
||||
if [ -z "$GITHUB_ORG" ]; then
|
||||
echo "ERROR! Failed to get [GITHUB_ORG]!"
|
||||
echo "ERROR:[$GITHUB_ORG]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_ORG]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GITHUB_ORG], value:[$GITHUB_ORG]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[$GITHUB_ORG]${NC}"
|
||||
fi
|
||||
|
||||
#######################
|
||||
|
@ -623,11 +625,11 @@ GetGitHubVars()
|
|||
# Validate we have a value #
|
||||
############################
|
||||
if [ -z "$GITHUB_REPO" ]; then
|
||||
echo "ERROR! Failed to get [GITHUB_REPO]!"
|
||||
echo "ERROR:[$GITHUB_REPO]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_REPO]${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully found:[GITHUB_REPO], value:[$GITHUB_REPO]"
|
||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[$GITHUB_REPO]${NC}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -662,14 +664,14 @@ function ValidatePowershellModules()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Failed
|
||||
echo "ERROR! Failed find module [PSScriptAnalyzer] for [$LINTER_NAME] in system!"
|
||||
echo "ERROR:[PSSA_MODULE $VALIDATE_PSSA_MODULE] [PSSA_CMD $VALIDATE_PSSA_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [$LINTER_NAME] in system!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE $VALIDATE_PSSA_MODULE] [PSSA_CMD $VALIDATE_PSSA_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# Success
|
||||
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
||||
echo "Successfully found module [$VALIDATE_PSSA_MODULE] in system"
|
||||
echo "Successfully found command [$VALIDATE_PSSA_CMD] in system"
|
||||
echo -e "${NC}${F[B]}Successfully found module ${F[W]}[$VALIDATE_PSSA_MODULE]${F[B]} in system${NC}"
|
||||
echo -e "${NC}${F[B]}Successfully found command ${F[W]}[$VALIDATE_PSSA_CMD]${F[B]} in system${NC}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -700,7 +702,7 @@ Footer()
|
|||
##################
|
||||
if [ "${!ERROR_COUNTER}" -ne 0 ]; then
|
||||
# Print the goods
|
||||
echo "ERRORS FOUND in $LANGUAGE:[${!ERROR_COUNTER}]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in $LANGUAGE:[${!ERROR_COUNTER}]${NC}"
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -708,7 +710,7 @@ Footer()
|
|||
# Exit with 0 if errors disabled #
|
||||
##################################
|
||||
if [ "$DISABLE_ERRORS" == "true" ]; then
|
||||
echo "WARN! Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]"
|
||||
echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]${NC}"
|
||||
exit 0
|
||||
###############################
|
||||
# Exit with 1 if errors found #
|
||||
|
@ -740,14 +742,14 @@ Footer()
|
|||
[ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then
|
||||
# Failed exit
|
||||
echo "Exiting with errors found!"
|
||||
echo -e "${NC}${F[R]}Exiting with errors found!${NC}"
|
||||
exit 1
|
||||
else
|
||||
#################
|
||||
# Footer prints #
|
||||
#################
|
||||
echo ""
|
||||
echo "All file(s) linted successfully with no errors detected"
|
||||
echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}"
|
||||
echo "----------------------------------------------"
|
||||
echo ""
|
||||
# Successful exit
|
||||
|
|
27
lib/termColors.sh
Normal file
27
lib/termColors.sh
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
declare -Agr B=(
|
||||
[B]=$(echo -e "\e[44m")
|
||||
[C]=$(echo -e "\e[46m")
|
||||
[G]=$(echo -e "\e[42m")
|
||||
[K]=$(echo -e "\e[40m")
|
||||
[M]=$(echo -e "\e[45m")
|
||||
[R]=$(echo -e "\e[41m")
|
||||
[W]=$(echo -e "\e[47m")
|
||||
[Y]=$(echo -e "\e[43m")
|
||||
)
|
||||
declare -Agr F=(
|
||||
[B]=$(echo -e "\e[0;34m")
|
||||
[C]=$(echo -e "\e[0;36m")
|
||||
[G]=$(echo -e "\e[0;32m")
|
||||
[K]=$(echo -e "\e[0;30m")
|
||||
[M]=$(echo -e "\e[0;35m")
|
||||
[R]=$(echo -e "\e[0;31m")
|
||||
[W]=$(echo -e "\e[0;37m")
|
||||
[Y]=$(echo -e "\e[0;33m")
|
||||
)
|
||||
readonly NC=$(echo -e "\e[0m")
|
||||
|
||||
export B
|
||||
export F
|
||||
export NC
|
|
@ -50,13 +50,13 @@ function LintCodebase()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Failed
|
||||
echo "ERROR! Failed to find [$LINTER_NAME] in system!"
|
||||
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# Success
|
||||
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
||||
echo "Successfully found binary for [$LINTER_NAME] in system"
|
||||
echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[$LINTER_NAME]${F[B]} in system${NC}"
|
||||
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
||||
fi
|
||||
fi
|
||||
|
@ -187,15 +187,15 @@ function LintCodebase()
|
|||
#########
|
||||
# Error #
|
||||
#########
|
||||
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
||||
echo "ERROR:[$LINT_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
|
||||
# Increment the error count
|
||||
(("ERRORS_FOUND_$FILE_TYPE++"))
|
||||
else
|
||||
###########
|
||||
# Success #
|
||||
###########
|
||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
||||
echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
@ -240,12 +240,12 @@ function TestCodebase()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Failed
|
||||
echo "ERROR! Failed to find [$LINTER_NAME] in system!"
|
||||
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# Success
|
||||
echo "Successfully found binary in system"
|
||||
echo -e "${NC}${F[B]}Successfully found binary in system${NC}"
|
||||
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
||||
fi
|
||||
|
||||
|
@ -358,9 +358,9 @@ function TestCodebase()
|
|||
#########
|
||||
# Error #
|
||||
#########
|
||||
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
||||
echo "ERROR:[$LINT_CMD]"
|
||||
echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]${NC}"
|
||||
# Increment the error count
|
||||
(("ERRORS_FOUND_$FILE_TYPE++"))
|
||||
# Increment counter that check was ran
|
||||
|
@ -369,7 +369,7 @@ function TestCodebase()
|
|||
###########
|
||||
# Success #
|
||||
###########
|
||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
||||
echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
|
||||
# Increment counter that check was ran
|
||||
((TESTS_RAN++))
|
||||
fi
|
||||
|
@ -384,10 +384,10 @@ function TestCodebase()
|
|||
#########
|
||||
# Error #
|
||||
#########
|
||||
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
||||
echo "ERROR! This file should have failed test case!"
|
||||
echo "ERROR:[$LINT_CMD]"
|
||||
echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]${NC}"
|
||||
# Increment the error count
|
||||
(("ERRORS_FOUND_$FILE_TYPE++"))
|
||||
# Increment counter that check was ran
|
||||
|
@ -396,7 +396,7 @@ function TestCodebase()
|
|||
###########
|
||||
# Success #
|
||||
###########
|
||||
echo " - File:[$FILE_NAME] failed test case with [$LINTER_NAME] successfully"
|
||||
echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} failed test case with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
|
||||
# Increment counter that check was ran
|
||||
((TESTS_RAN++))
|
||||
fi
|
||||
|
@ -410,7 +410,7 @@ function TestCodebase()
|
|||
#################################################
|
||||
# We failed to find files and no tests were ran #
|
||||
#################################################
|
||||
echo "ERROR! Failed to find any tests ran for the Linter:[$LINTER_NAME]"!
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[$LINTER_NAME]${NC}"!
|
||||
echo "Please validate logic or that tests exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -513,14 +513,14 @@ function LintAnsibleFiles()
|
|||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ]; then
|
||||
# Failed
|
||||
echo "ERROR! Failed to find $LINTER_NAME in system!"
|
||||
echo "ERROR:[$VALIDATE_INSTALL_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find $LINTER_NAME in system!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}"
|
||||
exit 1
|
||||
else
|
||||
# Success
|
||||
if [[ "$ACTIONS_RUNNER_DEBUG" == "true" ]]; then
|
||||
# Success
|
||||
echo "Successfully found binary in system"
|
||||
echo -e "${NC}${F[B]}Successfully found binary in system${NC}"
|
||||
echo "Location:[$VALIDATE_INSTALL_CMD]"
|
||||
fi
|
||||
fi
|
||||
|
@ -619,15 +619,15 @@ function LintAnsibleFiles()
|
|||
#########
|
||||
# Error #
|
||||
#########
|
||||
echo "ERROR! Found errors in [$LINTER_NAME] linter!"
|
||||
echo "ERROR:[$LINT_CMD]"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}"
|
||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
|
||||
# Increment error count
|
||||
((ERRORS_FOUND_ANSIBLE++))
|
||||
else
|
||||
###########
|
||||
# Success #
|
||||
###########
|
||||
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
|
||||
echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
|
||||
fi
|
||||
done
|
||||
else # No ansible directory found in path
|
||||
|
@ -638,7 +638,7 @@ function LintAnsibleFiles()
|
|||
########################
|
||||
# No Ansible dir found #
|
||||
########################
|
||||
echo "WARN! No Ansible base directory found at:[$ANSIBLE_DIRECTORY]"
|
||||
echo -e "${NC}${F[Y]}WARN!${NC} No Ansible base directory found at:[$ANSIBLE_DIRECTORY]${NC}"
|
||||
echo "skipping ansible lint"
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue