ci: fix CI skip script hole (#21741)

In some environments, the script will not fail despite SKIP_CHECK_BRANCH
being unset, leading to the script explicitly skipping CI when it should
fail fast.

Prevent this by explicitly checking for the env var.
This commit is contained in:
Michael Zalimeni 2024-09-16 16:35:49 -04:00 committed by GitHub
parent 17d43c6316
commit 5e20e13c8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -13,7 +13,8 @@ set -euo pipefail
#
# ... `git merge-base origin/$SKIP_CHECK_BRANCH HEAD` would return commit `D`
# `...HEAD` specifies from the common ancestor to the latest commit on the current branch (HEAD)..
files_to_check=$(git diff --name-only "$(git merge-base origin/$SKIP_CHECK_BRANCH HEAD~)"...HEAD)
skip_check_branch=${SKIP_CHECK_BRANCH:?SKIP_CHECK_BRANCH is required}
files_to_check=$(git diff --name-only "$(git merge-base origin/$skip_check_branch HEAD~)"...HEAD)
# Define the directories to check
skipped_directories=("docs/" "ui/" "website/" "grafana/" ".changelog/")
@ -46,4 +47,4 @@ for file_to_check in "${files_to_check_array[@]}"; do
done
echo "Changes detected in only documentation files - skipping tests and build"
echo "skip-ci=true" >> "$GITHUB_OUTPUT"
echo "skip-ci=true" >> "$GITHUB_OUTPUT"