From b7c659c0a94c14006f7e9ee1589d07973f042faf Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Fri, 5 May 2023 13:20:55 +0200 Subject: [PATCH] pipeline: gha: fix `IMAGES_ONLY_OUTDATED_ARTIFACTS` and `SKIP_IMAGES` by exporting them so Python can see; tune logging --- lib/functions/cli/cli-jsoninfo.sh | 3 +++ lib/tools/common/gha.py | 2 +- lib/tools/info/output-gha-matrix.py | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/functions/cli/cli-jsoninfo.sh b/lib/functions/cli/cli-jsoninfo.sh index a2f89713a..d9873e7c5 100644 --- a/lib/functions/cli/cli-jsoninfo.sh +++ b/lib/functions/cli/cli-jsoninfo.sh @@ -189,6 +189,9 @@ function cli_json_info_run() { display_alert "Generating GHA matrix for images" "output-gha-matrix :: images" "info" declare GHA_ALL_IMAGES_JSON_MATRIX_FILE="${BASE_INFO_OUTPUT_DIR}/gha-all-images-matrix.json" if [[ ! -f "${GHA_ALL_IMAGES_JSON_MATRIX_FILE}" ]]; then + # export env vars used by the Python script. + export SKIP_IMAGES="${SKIP_IMAGES:-"no"}" + export IMAGES_ONLY_OUTDATED_ARTIFACTS="${IMAGES_ONLY_OUTDATED_ARTIFACTS:-"no"}" run_host_command_logged "${PYTHON3_VARS[@]}" "${PYTHON3_INFO[BIN]}" "${INFO_TOOLS_DIR}"/output-gha-matrix.py images "${OUTDATED_ARTIFACTS_IMAGES_FILE}" "${MATRIX_IMAGE_CHUNKS}" ">" "${GHA_ALL_IMAGES_JSON_MATRIX_FILE}" fi github_actions_add_output "image-matrix" "$(cat "${GHA_ALL_IMAGES_JSON_MATRIX_FILE}")" diff --git a/lib/tools/common/gha.py b/lib/tools/common/gha.py index 76e617612..a4320de5e 100644 --- a/lib/tools/common/gha.py +++ b/lib/tools/common/gha.py @@ -11,7 +11,7 @@ def wrap_with_gha_expression(value): def set_gha_output(name, value): if os.environ.get('GITHUB_OUTPUT') is None: - log.warning(f"Environment variable GITHUB_OUTPUT is not set. Cannot set output '{name}' to '{value}'") + log.debug(f"Environment variable GITHUB_OUTPUT is not set. Cannot set output '{name}' to '{value}'") return with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: diff --git a/lib/tools/info/output-gha-matrix.py b/lib/tools/info/output-gha-matrix.py index 84993255b..b0da27ae2 100644 --- a/lib/tools/info/output-gha-matrix.py +++ b/lib/tools/info/output-gha-matrix.py @@ -76,9 +76,10 @@ def generate_matrix_images(info) -> list[dict]: image = info["images"][image_id] if armbian_utils.get_from_env("IMAGES_ONLY_OUTDATED_ARTIFACTS") == "yes": + log.info(f"IMAGES_ONLY_OUTDATED_ARTIFACTS is set: outdated artifacts: {image['outdated_artifacts_count']} for image {image_id}") skip = image["outdated_artifacts_count"] == 0 if skip: - log.info(f"Skipping image {image_id} because it has no outdated artifacts") + log.warning(f"Skipping image {image_id} because it has no outdated artifacts") continue if armbian_utils.get_from_env("SKIP_IMAGES") == "yes":