diff --git a/.github/actions/pre-job/action.yml b/.github/actions/pre-job/action.yml index 0202a37260..8d34feb4f8 100644 --- a/.github/actions/pre-job/action.yml +++ b/.github/actions/pre-job/action.yml @@ -95,11 +95,59 @@ runs: - name: Check force paths if: ${{ steps.check-conditions.outputs.needs_path_filtering == 'true' && inputs.force-filters != '' }} id: force_paths + shell: python + env: + FORCE_FILTERS: ${{ inputs.force-filters }} + GITHUB_OUTPUT: ${{ env.GITHUB_OUTPUT }} + run: | + import os + import yaml + + # Get the force filters input + force_filters_input = os.environ.get('FORCE_FILTERS', '').strip() + + if not force_filters_input: + print("No force filters provided") + exit(0) + + try: + # Parse the force-filters as YAML - should be an array of paths + force_paths_list = yaml.safe_load(force_filters_input) + + # Ensure it's a list + if not isinstance(force_paths_list, list): + raise ValueError("force-filters must be a YAML array of paths") + + if not force_paths_list: + print("No valid paths found in force-filters") + exit(0) + + # Create the YAML structure for paths-filter + force_paths_config = { + 'force-paths': force_paths_list + } + + # Generate YAML string directly + force_paths_yaml = yaml.dump(force_paths_config, default_flow_style=False) + + print("Generated force paths YAML:") + print(force_paths_yaml) + + # Set GitHub Actions output + with open(os.environ['GITHUB_OUTPUT'], 'a') as f: + f.write(f"force-paths-yaml<