From 8aed7c9a3b208b63535d89f66bde0f57172ab1d9 Mon Sep 17 00:00:00 2001 From: "ivan.ruzavin" Date: Mon, 21 Oct 2024 11:36:41 +0200 Subject: [PATCH] Fixed check index manual run flow --- .github/workflows/checkIndexes.yaml | 10 ++++++++-- scripts/check_indexes.py | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checkIndexes.yaml b/.github/workflows/checkIndexes.yaml index a36bd6fad..d3d4df23f 100644 --- a/.github/workflows/checkIndexes.yaml +++ b/.github/workflows/checkIndexes.yaml @@ -48,13 +48,19 @@ jobs: - name: Check Indexed Links - Live if: ${{ github.event.inputs.select_index == 'Live' || github.event.inputs.select_index == 'Both' }} run: | - python -u scripts/check_indexes.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_HOST }} ${{ secrets.ES_USER }} ${{ secrets.ES_PASSWORD }} ${{ secrets.ES_INDEX_LIVE }} "--es_regex" "${{ github.event.inputs.regex }}" "--log_only" ${{ !github.event.inputs.fix }} + FIX_ACTION=${{ github.event.inputs.fix }} # Capture the fix input + LOG_ONLY=$([[ "$FIX_ACTION" == "false" ]] && echo true || echo false) # Negate the fix input + echo "LOG_ONLY is set to $LOG_ONLY" + python -u scripts/check_indexes.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_HOST }} ${{ secrets.ES_USER }} ${{ secrets.ES_PASSWORD }} ${{ secrets.ES_INDEX_LIVE }} "--es_regex" "${{ github.event.inputs.regex }}" "--log_only" "$LOG_ONLY" continue-on-error: true # Ensure the workflow continues - name: Check Indexed Links - Test if: ${{ github.event.inputs.select_index == 'Test' || github.event.inputs.select_index == 'Both' }} run: | - python -u scripts/check_indexes.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_HOST }} ${{ secrets.ES_USER }} ${{ secrets.ES_PASSWORD }} ${{ secrets.ES_INDEX_TEST }} "--es_regex" "${{ github.event.inputs.regex }}" "--log_only" ${{ !github.event.inputs.fix }} + FIX_ACTION=${{ github.event.inputs.fix }} # Capture the fix input + LOG_ONLY=$([[ "$FIX_ACTION" == "false" ]] && echo true || echo false) # Negate the fix input + echo "LOG_ONLY is set to $LOG_ONLY" + python -u scripts/check_indexes.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.ES_HOST }} ${{ secrets.ES_USER }} ${{ secrets.ES_PASSWORD }} ${{ secrets.ES_INDEX_TEST }} "--es_regex" "${{ github.event.inputs.regex }}" "--log_only" "$LOG_ONLY" continue-on-error: true # Ensure the workflow continues push_to_main_run: diff --git a/scripts/check_indexes.py b/scripts/check_indexes.py index 7671b7f5d..4a98ee685 100644 --- a/scripts/check_indexes.py +++ b/scripts/check_indexes.py @@ -4,6 +4,17 @@ import classes.class_es as es if __name__ == "__main__": + # First, check for arguments passed + def str2bool(v): + if isinstance(v, bool): + return v + if v.lower() in ('yes', 'true', 't', 'y', '1'): + return True + elif v.lower() in ('no', 'false', 'f', 'n', '0'): + return False + else: + raise argparse.ArgumentTypeError('Boolean value expected.') + # Get arguments parser = argparse.ArgumentParser(description="Upload directories as release assets.") parser.add_argument("gh_repo", help="Github repository name, e.g., 'username/repo'", type=str) @@ -13,8 +24,8 @@ parser.add_argument("es_password", help="ES instance password value", type=str) parser.add_argument("es_index", help="ES instance index value", type=str) parser.add_argument("--es_regex", help="Regex to use to fetch indexed items", type=str, default=".+") - parser.add_argument("--log_only", help="If True, will not fix broken links, just log them to std out", type=bool, default=False) - parser.add_argument("--index_package_names", help="If True, will add \"gh_package_name\" to indexed item", type=bool, default=True) + parser.add_argument("--log_only", help="If True, will not fix broken links, just log them to std out", type=str2bool, default=False) + parser.add_argument("--index_package_names", help="If True, will add \"gh_package_name\" to indexed item", type=str2bool, default=True) args = parser.parse_args() es_instance = es.index(