mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-09 10:33:37 -05:00
Validate docker labels in the DEV workflow
This commit is contained in:
parent
d3c992bec7
commit
7380bad950
2 changed files with 91 additions and 1 deletions
77
.automation/validate-docker-labels.sh
Executable file
77
.automation/validate-docker-labels.sh
Executable file
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
################################################################################
|
||||
############# Clean all code base for additonal testing @admiralawkbar #########
|
||||
################################################################################
|
||||
|
||||
###########
|
||||
# Globals #
|
||||
###########
|
||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # GitHub Workspace
|
||||
GITHUB_SHA="${GITHUB_SHA}" # Sha used to create this branch
|
||||
BUILD_DATE="${BUILD_DATE}"
|
||||
BUILD_REVISION="${GITHUB_SHA}"
|
||||
BUILD_VERSION="${GITHUB_SHA}"
|
||||
ERROR=0
|
||||
|
||||
#########################
|
||||
# Source Function Files #
|
||||
#########################
|
||||
# shellcheck source=/dev/null
|
||||
source "${GITHUB_WORKSPACE}/lib/log.sh" # Source the function script(s)
|
||||
|
||||
################################################################################
|
||||
############################ FUNCTIONS BELOW ###################################
|
||||
################################################################################
|
||||
################################################################################
|
||||
#### Function Header ###########################################################
|
||||
Header() {
|
||||
info "--------------------------------------------------"
|
||||
info "----- GitHub Actions validate docker labels ------"
|
||||
info "--------------------------------------------------"
|
||||
}
|
||||
################################################################################
|
||||
#### Function ValidateLabel ####################################################
|
||||
ValidateLabel() {
|
||||
LABEL=$(docker inspect --format "{{ index .Config.Labels \"$1\" }}" github/super-linter:"${GITHUB_SHA}")
|
||||
if [[ ${LABEL} != "$2" ]]; then
|
||||
error "Assert failed [$1 - '${LABEL}' != '$2']"
|
||||
ERROR=1
|
||||
else
|
||||
info "Assert passed [$1]"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
#### Function Footer ###########################################################
|
||||
Footer() {
|
||||
if [[ ${ERROR} -gt 0 ]]; then
|
||||
fatal "There were some failed assertions. See above"
|
||||
else
|
||||
info "-------------------------------------------------------"
|
||||
info "The step has completed"
|
||||
info "-------------------------------------------------------"
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
################################## MAIN ########################################
|
||||
################################################################################
|
||||
|
||||
####################
|
||||
# Validate created #
|
||||
####################
|
||||
ValidateLabel "org.opencontainers.image.created" "${BUILD_DATE}"
|
||||
|
||||
#####################
|
||||
# Validate revision #
|
||||
#####################
|
||||
ValidateLabel "org.opencontainers.image.revision" "${BUILD_REVISION}"
|
||||
|
||||
####################
|
||||
# Validate version #
|
||||
####################
|
||||
ValidateLabel "org.opencontainers.image.version" "${BUILD_VERSION}"
|
||||
|
||||
#################
|
||||
# Report status #
|
||||
#################
|
||||
Footer
|
15
.github/workflows/deploy-DEV.yml
vendored
15
.github/workflows/deploy-DEV.yml
vendored
|
@ -43,12 +43,18 @@ jobs:
|
|||
- name: Checkout Code
|
||||
uses: actions/checkout@v2.3.2
|
||||
|
||||
########################
|
||||
# Get the current date #
|
||||
########################
|
||||
- name: Get current date
|
||||
run: echo "::set-env name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
|
||||
###################################
|
||||
# Build image locally for testing #
|
||||
###################################
|
||||
- name: Build image
|
||||
shell: bash
|
||||
run: docker build --no-cache -t github/super-linter:${GITHUB_SHA} .
|
||||
run: docker build --build-arg "BUILD_DATE=${BUILD_DATE}" --build-arg "BUILD_REVISION=${GITHUB_SHA}" --build-arg "BUILD_VERSION=${GITHUB_SHA}" --no-cache -t github/super-linter:${GITHUB_SHA} .
|
||||
|
||||
#####################################
|
||||
# Run Linter against Test code base #
|
||||
|
@ -70,3 +76,10 @@ jobs:
|
|||
- name: Run against all code base
|
||||
shell: bash
|
||||
run: docker run -e RUN_LOCAL=true -e OUTPUT_DETAILS=detailed -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
|
||||
|
||||
########################################
|
||||
# Validates the metadata docker labels #
|
||||
########################################
|
||||
- name: Run Docker label test cases
|
||||
shell: bash
|
||||
run: .automation/validate-docker-labels.sh
|
||||
|
|
Loading…
Reference in a new issue