Skip to content

Commit 2d77537

Browse files
Merge pull request #113 from MikroElektronika/fix/index-workflow-update
Fixed check index manual run flow
2 parents 7898353 + 8aed7c9 commit 2d77537

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

.github/workflows/checkIndexes.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,19 @@ jobs:
4848
- name: Check Indexed Links - Live
4949
if: ${{ github.event.inputs.select_index == 'Live' || github.event.inputs.select_index == 'Both' }}
5050
run: |
51-
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 }}
51+
FIX_ACTION=${{ github.event.inputs.fix }} # Capture the fix input
52+
LOG_ONLY=$([[ "$FIX_ACTION" == "false" ]] && echo true || echo false) # Negate the fix input
53+
echo "LOG_ONLY is set to $LOG_ONLY"
54+
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"
5255
continue-on-error: true # Ensure the workflow continues
5356

5457
- name: Check Indexed Links - Test
5558
if: ${{ github.event.inputs.select_index == 'Test' || github.event.inputs.select_index == 'Both' }}
5659
run: |
57-
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 }}
60+
FIX_ACTION=${{ github.event.inputs.fix }} # Capture the fix input
61+
LOG_ONLY=$([[ "$FIX_ACTION" == "false" ]] && echo true || echo false) # Negate the fix input
62+
echo "LOG_ONLY is set to $LOG_ONLY"
63+
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"
5864
continue-on-error: true # Ensure the workflow continues
5965

6066
push_to_main_run:

scripts/check_indexes.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
import classes.class_es as es
55

66
if __name__ == "__main__":
7+
# First, check for arguments passed
8+
def str2bool(v):
9+
if isinstance(v, bool):
10+
return v
11+
if v.lower() in ('yes', 'true', 't', 'y', '1'):
12+
return True
13+
elif v.lower() in ('no', 'false', 'f', 'n', '0'):
14+
return False
15+
else:
16+
raise argparse.ArgumentTypeError('Boolean value expected.')
17+
718
# Get arguments
819
parser = argparse.ArgumentParser(description="Upload directories as release assets.")
920
parser.add_argument("gh_repo", help="Github repository name, e.g., 'username/repo'", type=str)
@@ -13,8 +24,8 @@
1324
parser.add_argument("es_password", help="ES instance password value", type=str)
1425
parser.add_argument("es_index", help="ES instance index value", type=str)
1526
parser.add_argument("--es_regex", help="Regex to use to fetch indexed items", type=str, default=".+")
16-
parser.add_argument("--log_only", help="If True, will not fix broken links, just log them to std out", type=bool, default=False)
17-
parser.add_argument("--index_package_names", help="If True, will add \"gh_package_name\" to indexed item", type=bool, default=True)
27+
parser.add_argument("--log_only", help="If True, will not fix broken links, just log them to std out", type=str2bool, default=False)
28+
parser.add_argument("--index_package_names", help="If True, will add \"gh_package_name\" to indexed item", type=str2bool, default=True)
1829
args = parser.parse_args()
1930

2031
es_instance = es.index(

0 commit comments

Comments
 (0)