Skip to content
Snippets Groups Projects
Unverified Commit 37411bed authored by Florian Forster's avatar Florian Forster
Browse files

chore(yamlfmt): Print file contents in blue.

parent e6f7afb7
No related branches found
No related tags found
No related merge requests found
Pipeline #24649444 passed
Loading
Loading
@@ -11,26 +11,35 @@ yamlfmt:
name: registry.gitlab.com/gitlab-com/gl-infra/common-ci-tasks-images/yamlfmt:${GL_ASDF_YAMLFMT_VERSION}
entrypoint: [""]
script:
- |
# Terminal colors
bright_red="$(printf "\e[31;1m")"
blue="$(printf "\e[34m")"
color_reset="$(printf "\e[0m")"
- |
# Dump yamlfmt config
echo "# /etc/yamlfmt.yaml"
echo -n "${blue}"
cat /etc/yamlfmt.yaml
echo -n "${color_reset}"
- |
# Dump pattern file
PATTERN_FILES=("/etc/yamlfmt.patterns")
if [[ -e .yamlfmt.patterns ]]; then
PATTERN_FILES+=(".yamlfmt.patterns")
fi
echo "# ${PATTERN_FILES[@]}"
cat "${PATTERN_FILES[@]}"
for pattern_file in "${PATTERN_FILES[@]}"; do
echo "# ${pattern_file}"
echo -n "${blue}"
cat "${pattern_file}"
echo -n "${color_reset}"
done
- yamlfmt -conf /etc/yamlfmt.yaml "${PATTERN_FILES[@]}"
- git diff | tee yamlfmt.patch
- |
if [[ -s yamlfmt.patch ]]; then
red="$(printf "\e[31;1m")"
reset="$(printf "\e[0m")"
echo "${red}Some YAML files are not formatted correctly. Run the following command in the repository root to fix:${reset}"
echo "${red}# curl ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/yamlfmt.patch | patch -p1${reset}"
echo "${bright_red}Some YAML files are not formatted correctly. Run the following command in the repository root to fix:${color_reset}"
echo "${bright_red}# curl ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/yamlfmt.patch | patch -p1${color_reset}"
exit 1
fi
after_script: |
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment