File tree 1 file changed +21
-10
lines changed
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
2
2
name : Update Directory
3
+ permissions :
4
+ contents : write
3
5
on :
4
6
push :
5
7
paths :
6
8
- ' src/**'
7
- - ' **.yml'
8
- - ' **.xml'
9
- - ' **.Dockerfile'
10
9
pull_request :
11
10
paths :
12
11
- ' 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
16
23
jobs :
17
24
update_directory_md :
18
25
runs-on : ubuntu-latest
46
53
def print_path(old_path: str, new_path: str) -> str:
47
54
global g_output
48
55
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
51
62
if new_part:
52
63
g_output.append(f"{md_prefix(i)} {new_part.replace('_', ' ')}")
53
64
return new_path
56
67
def build_directory_md(top_dir: str = ".") -> str:
57
68
global g_output
58
69
old_path = ""
59
- for filepath in sorted(good_filepaths(), key=str.lower):
70
+ for filepath in sorted(good_filepaths(top_dir ), key=str.lower):
60
71
filepath, filename = os.path.split(filepath)
61
72
if filepath != old_path:
62
73
old_path = print_path(old_path, filepath)
You can’t perform that action at this time.
0 commit comments