mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
31
.github/workflows/update_directory.yml
vendored
31
.github/workflows/update_directory.yml
vendored
@@ -1,18 +1,25 @@
|
||||
# This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push
|
||||
# This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push or pull_request
|
||||
name: Update Directory
|
||||
permissions:
|
||||
contents: write
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- '**.yml'
|
||||
- '**.xml'
|
||||
- '**.Dockerfile'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- '**.yml'
|
||||
- '**.xml'
|
||||
- '**.Dockerfile'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
logLevel:
|
||||
description: 'Log level'
|
||||
required: true
|
||||
default: 'info'
|
||||
type: choice
|
||||
options:
|
||||
- info
|
||||
- warning
|
||||
- debug
|
||||
jobs:
|
||||
update_directory_md:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -46,8 +53,12 @@ jobs:
|
||||
def print_path(old_path: str, new_path: str) -> str:
|
||||
global g_output
|
||||
old_parts = old_path.split(os.sep)
|
||||
for i, new_part in enumerate(new_path.split(os.sep)):
|
||||
if i + 1 > len(old_parts) or old_parts[i] != new_part:
|
||||
mid_diff = False
|
||||
new_parts = new_path.split(os.sep)
|
||||
for i, new_part in enumerate(new_parts):
|
||||
if i + 1 > len(old_parts) or old_parts[i] != new_part or mid_diff:
|
||||
if i + 1 < len(new_parts):
|
||||
mid_diff = True
|
||||
if new_part:
|
||||
g_output.append(f"{md_prefix(i)} {new_part.replace('_', ' ')}")
|
||||
return new_path
|
||||
@@ -56,7 +67,7 @@ jobs:
|
||||
def build_directory_md(top_dir: str = ".") -> str:
|
||||
global g_output
|
||||
old_path = ""
|
||||
for filepath in sorted(good_filepaths(), key=str.lower):
|
||||
for filepath in sorted(good_filepaths(top_dir), key=str.lower):
|
||||
filepath, filename = os.path.split(filepath)
|
||||
if filepath != old_path:
|
||||
old_path = print_path(old_path, filepath)
|
||||
|
||||
Reference in New Issue
Block a user