Skip to content

Commit 2ac5429

Browse files
committed
jekyll build from Action a18c821
0 parents  commit 2ac5429

File tree

142 files changed

+21008
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+21008
-0
lines changed

.nojekyll

Whitespace-only changes.

action.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import argparse
2+
import os
3+
import glob
4+
5+
class GithubAction:
6+
def get_cli_args(self):
7+
parser = argparse.ArgumentParser()
8+
parser.add_argument('-repo', required=True)
9+
parser.add_argument('-access_token', required=True)
10+
parser.add_argument('-commit_author', required=True)
11+
parser.add_argument('-commit_user_email', required=True)
12+
parser.add_argument('-commit_message', required=True)
13+
parser.add_argument('-branch', required=True)
14+
parser.add_argument('-output_file_paths', required=True)
15+
parser.add_argument('-categories', required=True)
16+
cli_args = parser.parse_args()
17+
self.repo = cli_args.repo
18+
self.access_token = cli_args.access_token
19+
self.commit_author = cli_args.commit_author
20+
self.commit_user_email = cli_args.commit_user_email
21+
self.commit_message = cli_args.commit_message
22+
self.branch = (cli_args.branch).split("/")[-1]
23+
self.output_file_paths = cli_args.output_file_paths
24+
self.categories = cli_args.categories
25+
26+
def get_output_file_paths(self):
27+
file_paths = self.output_file_paths
28+
file_paths = file_paths.translate({ord(i):None for i in '[]" '})
29+
file_paths = file_paths.split(",")
30+
updated_file_paths = []
31+
for file_path in file_paths:
32+
updated_file_paths += glob.glob(file_path)
33+
updated_file_paths = [updated_file_path for updated_file_path in updated_file_paths if ".md" in updated_file_path]
34+
updated_file_paths = ' '.join(updated_file_paths)
35+
self.output_file_paths = updated_file_paths
36+
37+
def get_categories(self):
38+
categories = self.categories
39+
categories = categories.translate({ord(i):None for i in '[]" '})
40+
categories = categories.split(",")
41+
categories = ' '.join(categories)
42+
self.categories = categories
43+
44+
def start_markdown_autodocs(self):
45+
self.get_cli_args()
46+
self.get_output_file_paths()
47+
self.get_categories()
48+
ma_cli_command = f"markdown-autodocs --outputFilePath {self.output_file_paths} --category {self.categories} --repo {self.repo} --branch {self.branch} --accessToken {self.access_token}"
49+
print(f"ma_cli_command: {ma_cli_command}")
50+
os.system("sudo npm i -g markdown-autodocs")
51+
os.system(ma_cli_command)
52+
53+
def autodocument_markdown_files(self):
54+
self.start_markdown_autodocs()
55+
os.system(f"git config user.name '{self.commit_author}'")
56+
os.system(f"git config user.email '{self.commit_user_email}'")
57+
os.system(f"git add {self.output_file_paths}")
58+
os.system(f"git commit -m '{self.commit_message}' {self.output_file_paths}")
59+
os.system(f"git push origin {self.branch}")
60+
61+
if __name__ == "__main__":
62+
gh_action = GithubAction()
63+
gh_action.autodocument_markdown_files()

0 commit comments

Comments
 (0)