Update mysql kbase #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |