-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (77 loc) · 3.17 KB
/
build_contents_kbase_repo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Build_contents_kbase_repo
on:
push:
branches:
- master
jobs:
build_contens:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: master
- uses: actions/setup-python@v4.2.0
- name: Build
uses: jannekem/run-python-script-action@v1
id: script
with:
script: |
from pathlib import Path
tree_str = []
def generate_tree(pathname, n=0):
global tree_str
global base_path
if pathname.is_file():
if pathname.name.endswith(".md"):
temp = open(str(pathname.resolve()), "r").readlines()
for i in temp:
if i.startswith('# '):
i = i.replace('# ', '').rstrip()
tree_str.append({'type': 'file', 'level': n, 'name': i, 'path': str(
pathname.resolve()).replace(str(base_path.as_posix())+'/', '')})
elif pathname.is_dir() and pathname.name != ".git" and pathname.name != ".github":
tree_str.append({'type': 'dir', 'level': n, 'name': str(
pathname.relative_to(pathname.parent)), 'path': str(pathname.resolve()).replace(str(base_path.as_posix())+'/', '')})
open(str(pathname.resolve())+'/README.md', "w+")
for cp in sorted(pathname.iterdir(), key=os.path.basename):
generate_tree(cp, n + 1)
if __name__ == '__main__':
base_path = Path.cwd()
generate_tree(base_path)
for data in tree_str:
if data['type'] == 'dir':
with open(data['path']+'/README.md', "w") as outf:
for ds in tree_str:
if ds['path'].find(data['path']) > -1:
outf.write(
" " * 4 * (ds['level']-data['level']) + '* '"[" + ds['name'] + "](/" + ds['path'] + ") " "\n")
with open('README.md', "w") as lf:
lf.write("# База знаний # " + "\n")
for ds in tree_str:
if ds['level']>0:
lf.write(" " * 3 * (ds['level']) + '* '"[" + ds['name'] + "](/" + ds['path'] + ") " "\n")
- name: Print errors
if: steps.script.outputs.error == 'true'
run: |
printenv "SCRIPT_STDOUT"
printenv "SCRIPT_STDERR"
env:
SCRIPT_STDOUT: ${{ steps.script.outputs.stdout }}
SCRIPT_STDERR: ${{ steps.script.outputs.stderr }}
- name: GitHub Build Push
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Automated Deploy Change
branch: main
commit_options: '--no-verify --signoff'
commit_user_name: laspavel
commit_user_email: laspavel@gmain.com
commit_author: laspavel <laspavel@gmail.com>
add_options: '-u'
push_options: '--force'
skip_dirty_check: true
skip_fetch: true
skip_checkout: true
disable_globbing: true
create_branch: true