mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-29 17:41:00 -05:00
adding some dope code
This commit is contained in:
parent
ef99a48ce6
commit
17a4bd2271
4 changed files with 207 additions and 31 deletions
|
@ -18,16 +18,27 @@
|
||||||
# Globals #
|
# Globals #
|
||||||
###########
|
###########
|
||||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
||||||
|
GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" # GitHub Org/Repo passed from system
|
||||||
DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub
|
DOCKER_USERNAME="${DOCKER_USERNAME}" # Username to login to DockerHub
|
||||||
DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub
|
DOCKER_PASSWORD="${DOCKER_PASSWORD}" # Password to login to DockerHub
|
||||||
GPR_USERNAME="${GPR_USERNAME}" # Username to login to GitHub package registry
|
GCR_USERNAME="${GCR_USERNAME}" # Username to login to GitHub package registry
|
||||||
GPR_TOKEN="${GPR_TOKEN}" # Password to login to GitHub package registry
|
GCR_TOKEN="${GCR_TOKEN}" # Password to login to GitHub package registry
|
||||||
REGISTRY="${REGISTRY}" # What registry to upload | <GPR> or <Docker>
|
REGISTRY="${REGISTRY}" # What registry to upload | <GCR> or <Docker>
|
||||||
IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image
|
IMAGE_REPO="${IMAGE_REPO}" # Image repo to upload the image
|
||||||
IMAGE_VERSION="${IMAGE_VERSION}" # Version to tag the image
|
IMAGE_VERSION="${IMAGE_VERSION}" # Version to tag the image
|
||||||
DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded
|
DOCKERFILE_PATH="${DOCKERFILE_PATH}" # Path to the Dockerfile to be uploaded
|
||||||
MAJOR_TAG='' # Major tag version if we need to update it
|
MAJOR_TAG='' # Major tag version if we need to update it
|
||||||
UPDATE_MAJOR_TAG=0 # Flag to deploy the major tag version as well
|
UPDATE_MAJOR_TAG=0 # Flag to deploy the major tag version as well
|
||||||
|
GCR_URL='containers.pkg.github.com' # URL to Github Container Registry
|
||||||
|
DOCKER_IMAGE_REPO='' # Docker tag for the image when created
|
||||||
|
GCR_IMAGE_REPO='' # Docker tag for the image when created
|
||||||
|
FOUND_IMAGE=0 # Flag for if the image has already been built
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Get the org and repo names #
|
||||||
|
##############################
|
||||||
|
ORG_NAME=$(echo "${GITHUB_REPOSITORY}" |cut -f1 -d'/') # Github Organization Name
|
||||||
|
REPO_NAME=$(echo "${GITHUB_REPOSITORY}" |cut -f2 -d'/') # GitHub Repository name
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Source Function Files #
|
# Source Function Files #
|
||||||
|
@ -79,25 +90,25 @@ ValidateInput() {
|
||||||
#####################################################
|
#####################################################
|
||||||
# See if we need values for GitHub package Registry #
|
# See if we need values for GitHub package Registry #
|
||||||
#####################################################
|
#####################################################
|
||||||
if [[ ${REGISTRY} == "GPR" ]]; then
|
if [[ ${REGISTRY} == "GCR" ]]; then
|
||||||
#########################
|
#########################
|
||||||
# Validate GPR_USERNAME #
|
# Validate GCR_USERNAME #
|
||||||
#########################
|
#########################
|
||||||
if [ -z "${GPR_USERNAME}" ]; then
|
if [ -z "${GCR_USERNAME}" ]; then
|
||||||
error "Failed to get [GPR_USERNAME]!"
|
error "Failed to get [GCR_USERNAME]!"
|
||||||
fatal "[${GPR_USERNAME}]"
|
fatal "[${GCR_USERNAME}]"
|
||||||
else
|
else
|
||||||
info "Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]"
|
info "Successfully found:${F[W]}[GCR_USERNAME]${F[B]}, value:${F[W]}[${GCR_USERNAME}]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Validate GPR_TOKEN #
|
# Validate GCR_TOKEN #
|
||||||
######################
|
######################
|
||||||
if [ -z "${GPR_TOKEN}" ]; then
|
if [ -z "${GCR_TOKEN}" ]; then
|
||||||
error "Failed to get [GPR_TOKEN]!"
|
error "Failed to get [GCR_TOKEN]!"
|
||||||
fatal "[${GPR_TOKEN}]"
|
fatal "[${GCR_TOKEN}]"
|
||||||
else
|
else
|
||||||
info "Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]"
|
info "Successfully found:${F[W]}[GCR_TOKEN]${F[B]}, value:${F[W]}[********]"
|
||||||
fi
|
fi
|
||||||
########################################
|
########################################
|
||||||
# See if we need values for Ducker hub #
|
# See if we need values for Ducker hub #
|
||||||
|
@ -138,13 +149,15 @@ ValidateInput() {
|
||||||
fatal "[${IMAGE_REPO}]"
|
fatal "[${IMAGE_REPO}]"
|
||||||
else
|
else
|
||||||
info "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]"
|
info "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]"
|
||||||
|
DOCKER_IMAGE_REPO="${IMAGE_REPO}"
|
||||||
###############################################
|
###############################################
|
||||||
# Need to see if GPR registry and update name #
|
# Need to see if GCR registry and update name #
|
||||||
###############################################
|
###############################################
|
||||||
if [[ ${REGISTRY} == "GPR" ]]; then
|
if [[ ${REGISTRY} == "GCR" ]]; then
|
||||||
NAME="containers.pkg.github.com/${IMAGE_REPO}/super-linter"
|
NAME="${GCR_URL}/${IMAGE_REPO}/${REPO_NAME}"
|
||||||
IMAGE_REPO="${NAME}"
|
IMAGE_REPO="${NAME}"
|
||||||
info "Updated [IMAGE_REPO] to:[${IMAGE_REPO}] for GPR"
|
GCR_IMAGE_REPO="${IMAGE_REPO}"
|
||||||
|
info "Updated [IMAGE_REPO] to:[${IMAGE_REPO}] for GCR"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -326,6 +339,36 @@ BuildImage() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
#### Function TagBuiltImage ####################################################
|
||||||
|
TagBuiltImage() {
|
||||||
|
####################
|
||||||
|
# Pull in the vars #
|
||||||
|
####################
|
||||||
|
ORIGINAL_TAG="$1"
|
||||||
|
NEW_TAG="$2"
|
||||||
|
|
||||||
|
#################
|
||||||
|
# Tag the image #
|
||||||
|
#################
|
||||||
|
info "Re-Tagging image from:[${ORIGINAL_TAG}] to:[${NEW_TAG}]"
|
||||||
|
docker image tag "${ORIGINAL_TAG}" "${NEW_TAG}"
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Load the error code #
|
||||||
|
#######################
|
||||||
|
ERROR_CODE=$?
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
|
info "Successfully tag of image:[${NEW_TAG}]"
|
||||||
|
else
|
||||||
|
fatal "Failed to tag image:[${NEW_TAG}]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
################################################################################
|
||||||
#### Function UploadImage ######################################################
|
#### Function UploadImage ######################################################
|
||||||
UploadImage() {
|
UploadImage() {
|
||||||
################
|
################
|
||||||
|
@ -422,6 +465,117 @@ UploadImage() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
#### Function FindBuiltImage ###################################################
|
||||||
|
FindBuiltImage() {
|
||||||
|
# Check the local system to see if an image has already been built
|
||||||
|
# if so, we only need to update tags and push
|
||||||
|
# Set FOUND_IMAGE=1 when found
|
||||||
|
FOUND_DOCKER_RELASE=0
|
||||||
|
FOUND_DOCKER_MAJOR=0
|
||||||
|
FOUND_GCR_RELASE=0
|
||||||
|
FOUND_GCR_MAJOR=0
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Look for Release image in DockerHub #
|
||||||
|
#######################################
|
||||||
|
DOCKERHUB_FIND_CMD=$(docker images | grep "${DOCKER_IMAGE_REPO}" | grep ${IMAGE_VERSION} 2>&1)
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Load the error code #
|
||||||
|
#######################
|
||||||
|
ERROR_CODE=$?
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
|
info "Found Docker image:[$DOCKER_IMAGE_REPO:$IMAGE_VERSION] already built on instance"
|
||||||
|
FOUND_DOCKER_RELASE=1
|
||||||
|
else
|
||||||
|
info "Failed to find locally created Docker image:[$DOCKERHUB_FIND_CMD]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
# Look for Major image in DockerHub #
|
||||||
|
#####################################
|
||||||
|
DOCKERHUB_FIND_CMD=$(docker images | grep "${DOCKER_IMAGE_REPO}" | grep ${MAJOR_TAG} 2>&1)
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Load the error code #
|
||||||
|
#######################
|
||||||
|
ERROR_CODE=$?
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
|
info "Found Docker image:[$DOCKER_IMAGE_REPO:$MAJOR_TAG] already built on instance"
|
||||||
|
FOUND_DOCKER_MAJOR=1
|
||||||
|
else
|
||||||
|
info "Failed to find locally created Docker image:[$DOCKERHUB_FIND_CMD]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# Look for Release image in GitHub #
|
||||||
|
####################################
|
||||||
|
GCR_FIND_CMD=$(docker images | grep "${GCR_IMAGE_REPO}" | grep ${IMAGE_VERSION} 2>&1)
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Load the error code #
|
||||||
|
#######################
|
||||||
|
ERROR_CODE=$?
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
|
info "Found Docker image:[$GCR_IMAGE_REPO:$IMAGE_VERSION] already built on instance"
|
||||||
|
FOUND_GCR_RELASE=1
|
||||||
|
else
|
||||||
|
info "Failed to find locally created Docker image:[$GCR_FIND_CMD]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
##################################
|
||||||
|
# Look for Major image in GitHub #
|
||||||
|
##################################
|
||||||
|
GCR_FIND_CMD=$(docker images | grep "${GCR_IMAGE_REPO}" | grep ${MAJOR_TAG} 2>&1)
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Load the error code #
|
||||||
|
#######################
|
||||||
|
ERROR_CODE=$?
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
|
info "Found Docker image:[$GCR_IMAGE_REPO:$MAJOR_TAG] already built on instance"
|
||||||
|
FOUND_GCR_MAJOR=1
|
||||||
|
else
|
||||||
|
info "Failed to find locally created Docker image:[$GCR_FIND_CMD]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# Need to see if GCR registry push #
|
||||||
|
####################################
|
||||||
|
if [[ ${REGISTRY} == "GCR" ]]; then
|
||||||
|
if [ ${FOUND_DOCKER_MAJOR} -eq 1 ] && [ ${FOUND_DOCKER_RELASE} -eq 1 ]; then
|
||||||
|
# We have already created the images for dockerhub, need to re-tag and push
|
||||||
|
# Tag the image: TagBuiltImage "OldTag" "NewTag"
|
||||||
|
TagBuiltImage "${DOCKER_IMAGE_REPO}:${IMAGE_VERSION}" "$GCR_IMAGE_REPO:${IMAGE_VERSION}"
|
||||||
|
TagBuiltImage "${DOCKER_IMAGE_REPO}:${MAJOR_TAG}" "${GCR_IMAGE_REPO}:${MAJOR_TAG}"
|
||||||
|
FOUND_IMAGE=1
|
||||||
|
fi
|
||||||
|
elif [[ ${REGISTRY} == "Docker" ]]; then
|
||||||
|
if [ ${FOUND_GCR_MAJOR} -eq 1 ] && [ ${FOUND_GCR_RELASE} -eq 1 ]; then
|
||||||
|
# We have already created the images for GCR, need to re-tag and push
|
||||||
|
TagBuiltImage "$GCR_IMAGE_REPO:${IMAGE_VERSION}" "${DOCKER_IMAGE_REPO}:${IMAGE_VERSION}"
|
||||||
|
TagBuiltImage "${GCR_IMAGE_REPO}:${MAJOR_TAG}""${DOCKER_IMAGE_REPO}:${MAJOR_TAG}"
|
||||||
|
FOUND_IMAGE=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
################################################################################
|
||||||
#### Function Footer ###########################################################
|
#### Function Footer ###########################################################
|
||||||
Footer() {
|
Footer() {
|
||||||
info "-------------------------------------------------------"
|
info "-------------------------------------------------------"
|
||||||
|
@ -442,10 +596,17 @@ Header
|
||||||
##################
|
##################
|
||||||
ValidateInput
|
ValidateInput
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Find Image if already built #
|
||||||
|
###############################
|
||||||
|
FindBuiltImage
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# Build the image #
|
# Build the image #
|
||||||
###################
|
###################
|
||||||
|
if [ "$FOUND_IMAGE" -ne 0 ]; then
|
||||||
BuildImage
|
BuildImage
|
||||||
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Login to DockerHub #
|
# Login to DockerHub #
|
||||||
|
@ -457,9 +618,9 @@ if [[ ${REGISTRY} == "Docker" ]]; then
|
||||||
####################################
|
####################################
|
||||||
# Login to GitHub Package Registry #
|
# Login to GitHub Package Registry #
|
||||||
####################################
|
####################################
|
||||||
elif [[ ${REGISTRY} == "GPR" ]]; then
|
elif [[ ${REGISTRY} == "GCR" ]]; then
|
||||||
# Authenticate "Username" "Password" "Url" "Name"
|
# Authenticate "Username" "Password" "Url" "Name"
|
||||||
Authenticate "${GPR_USERNAME}" "${GPR_TOKEN}" "https://containers.pkg.github.com" "GitHub Package Registry"
|
Authenticate "${GCR_USERNAME}" "${GCR_TOKEN}" "https://${GCR_URL}" "GitHub Package Registry"
|
||||||
|
|
||||||
else
|
else
|
||||||
#########
|
#########
|
||||||
|
|
15
.github/workflows/deploy-PROD.yml
vendored
15
.github/workflows/deploy-PROD.yml
vendored
|
@ -53,3 +53,18 @@ jobs:
|
||||||
REGISTRY: Docker
|
REGISTRY: Docker
|
||||||
shell: bash
|
shell: bash
|
||||||
run: .automation/upload-docker.sh
|
run: .automation/upload-docker.sh
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Run Deploy script #
|
||||||
|
#####################
|
||||||
|
- name: Deploy latest image to GitHub Container Registry
|
||||||
|
env:
|
||||||
|
# Set the Env Vars
|
||||||
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
IMAGE_REPO: github/super-linter
|
||||||
|
IMAGE_VERSION: latest
|
||||||
|
DOCKERFILE_PATH: Dockerfile
|
||||||
|
REGISTRY: GPR
|
||||||
|
shell: bash
|
||||||
|
run: .automation/upload-docker.sh
|
||||||
|
|
2
.github/workflows/deploy-RELEASE.yml
vendored
2
.github/workflows/deploy-RELEASE.yml
vendored
|
@ -57,7 +57,7 @@ jobs:
|
||||||
#############################
|
#############################
|
||||||
# Run Deploy script for GPR #
|
# Run Deploy script for GPR #
|
||||||
#############################
|
#############################
|
||||||
- name: Deploy Release image to GitHub Package Registry
|
- name: Deploy Release image to GitHub Container Registry
|
||||||
env:
|
env:
|
||||||
# Set the Env Vars
|
# Set the Env Vars
|
||||||
GPR_USERNAME: ${{ secrets.GPR_USERNAME }}
|
GPR_USERNAME: ${{ secrets.GPR_USERNAME }}
|
||||||
|
|
|
@ -1744,7 +1744,7 @@ if [ "${VALIDATE_R}" == "true" ]; then
|
||||||
##########################
|
##########################
|
||||||
# Check for local config #
|
# Check for local config #
|
||||||
##########################
|
##########################
|
||||||
if [ ! -f "${GITHUB_WORKSPACE}/.lintr" ]; then
|
if [ ! -f "${GITHUB_WORKSPACE}/.lintr" ] && [ "${FILE_ARRAY_R[@]}" -ne 0 ]; then
|
||||||
info " "
|
info " "
|
||||||
info "No .lintr configuration file found, using defaults."
|
info "No .lintr configuration file found, using defaults."
|
||||||
cp $R_LINTER_RULES "$GITHUB_WORKSPACE"
|
cp $R_LINTER_RULES "$GITHUB_WORKSPACE"
|
||||||
|
|
Loading…
Reference in a new issue