File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed
Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change 1- # This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push
1+ # This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push or pull_request
22name : Update Directory
3+ permissions :
4+ contents : write
35on :
46 push :
57 paths :
68 - ' src/**'
7- - ' **.yml'
8- - ' **.xml'
9- - ' **.Dockerfile'
109 pull_request :
1110 paths :
1211 - ' src/**'
13- - ' **.yml'
14- - ' **.xml'
15- - ' **.Dockerfile'
12+ workflow_dispatch :
13+ inputs :
14+ logLevel :
15+ description : ' Log level'
16+ required : true
17+ default : ' info'
18+ type : choice
19+ options :
20+ - info
21+ - warning
22+ - debug
1623jobs :
1724 update_directory_md :
1825 runs-on : ubuntu-latest
4653 def print_path(old_path: str, new_path: str) -> str:
4754 global g_output
4855 old_parts = old_path.split(os.sep)
49- for i, new_part in enumerate(new_path.split(os.sep)):
50- if i + 1 > len(old_parts) or old_parts[i] != new_part:
56+ mid_diff = False
57+ new_parts = new_path.split(os.sep)
58+ for i, new_part in enumerate(new_parts):
59+ if i + 1 > len(old_parts) or old_parts[i] != new_part or mid_diff:
60+ if i + 1 < len(new_parts):
61+ mid_diff = True
5162 if new_part:
5263 g_output.append(f"{md_prefix(i)} {new_part.replace('_', ' ')}")
5364 return new_path
5667 def build_directory_md(top_dir: str = ".") -> str:
5768 global g_output
5869 old_path = ""
59- for filepath in sorted(good_filepaths(), key=str.lower):
70+ for filepath in sorted(good_filepaths(top_dir ), key=str.lower):
6071 filepath, filename = os.path.split(filepath)
6172 if filepath != old_path:
6273 old_path = print_path(old_path, filepath)
You can’t perform that action at this time.
0 commit comments