Skip to content
This repository has been archived by the owner on Sep 5, 2022. It is now read-only.

Commit

Permalink
feat: Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisandra-dev committed Apr 8, 2022
1 parent 11f4160 commit 8f2736c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
5 changes: 4 additions & 1 deletion mkdocs_obsidian/__main__.py
Expand Up @@ -250,6 +250,9 @@ def main():
parser.add_argument(
"--obsidian", "--shell", help=argparse.SUPPRESS, action="store_true"
)
parser.add_argument(
"--GA", "--actions", help=argparse.SUPPRESS, action="store_true"
)
console = Console()
args = parser.parse_args()
from mkdocs_obsidian.common import config as setup
Expand All @@ -262,7 +265,7 @@ def main():
setup.create_env(configuration_name)
sys.exit()
else:
configuration = setup.open_value(configuration_name)
configuration = setup.open_value(configuration_name, args.GA)
meta_update = int(args.meta)
no_git = args.git
if not args.keep:
Expand Down
27 changes: 20 additions & 7 deletions mkdocs_obsidian/common/config.py
Expand Up @@ -430,15 +430,16 @@ def git_push(
)


def open_value(configuration_name="0"):
def open_value(configuration_name="0", actions=False):
"""
Return the configuration value
Parameters
----------
configuration_name: str
The configuration name. If "0", use the default configuration, aka : .mkdocs_obsidian ;
Else use ".configuration_name"
actions: bool, default: False
If run in github actions
Returns
-------
dict [Path, Path, str, str, str, str, Path, Path, list[str]]:
Expand All @@ -463,9 +464,12 @@ def open_value(configuration_name="0"):
BASEDIR = BASEDIR.parent.absolute()
except ModuleNotFoundError:
pass
if configuration_name == "0":
if actions:
BASEDIR = os.getcwd()
configuration_name = 'source/.github-actions'
elif configuration_name == "0":
configuration_name = ".mkdocs_obsidian"
else:
elif not actions:
configuration_name = "." + configuration_name
ENV_PATH = Path(f"{BASEDIR}/{configuration_name}")

Expand All @@ -485,7 +489,10 @@ def open_value(configuration_name="0"):
# In case of error
env = dotenv_values(ENV_PATH)
try:
BASEDIR = Path(env["blog_path"]).expanduser()
if actions:
BASEDIR=os.getcwd()
else:
BASEDIR = Path(env["blog_path"]).expanduser()
VAULT = Path(env["vault"]).expanduser()
WEB = env["blog"]
try:
Expand All @@ -512,7 +519,10 @@ def open_value(configuration_name="0"):
basedir_str = "".join(f.readlines(2)).replace("blog_path=", "").rstrip()

VAULT = Path(vault_str)
BASEDIR = Path(basedir_str)
if actions:
BASEDIR = Path(os.getcwd())
else:
BASEDIR = Path(basedir_str)
WEB = "".join(f.readlines(3)).replace("blog=", "")
SHARE = "".join(f.readlines(4)).replace("share=", "")
INDEX_KEY = "".join(f.readlines(5)).replace("index_key=", "")
Expand All @@ -530,7 +540,10 @@ def open_value(configuration_name="0"):
if len(vault_str) == 0 or len(basedir_str) == 0 or len(WEB) == 0:
sys.exit("Please provide a valid path for all config items")
except RuntimeError:
BASEDIR = Path(env["blog_path"])
if actions:
BASEDIR = os.getcwd()
else:
BASEDIR = Path(env["blog_path"])
VAULT = Path(env["vault"])
WEB = env["blog"]
SHARE = env["share"]
Expand Down

0 comments on commit 8f2736c

Please sign in to comment.