8000 Write Git credentials to the config file. (#351) · ra2003/dry-python.github.io@06cb30b · GitHub
[go: up one dir, main page]

Skip to content

Commit 06cb30b

Browse files
authored
< 8000 div>Write Git credentials to the config file. (dry-python#351)
1 parent 9c2e4f8 commit 06cb30b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tasks.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from os import environ
2+
from os import getcwd
3+
from os.path import join
24< 8000 div class="diff-text-inner">
3-
from invoke import Responder
45
from invoke import task
56

67

@@ -25,7 +26,15 @@ def build(c):
2526

2627
@task
2728
def deploy(c):
28-
command = "poetry run ghp-import --cname dry-python.org --branch master --push site"
29-
enter_username = Responder(r"Username for .*:", environ["GIT_COMMITTER_NAME"])
30-
enter_password = Responder(r"Password for .*:", environ["GIT_COMMITTER_PASSWORD"])
31-
c.run(command, pty=True, watchers=[enter_username, enter_password])
29+
config_path = join(getcwd(), ".git", "config")
30+
cred_path = join(getcwd(), ".git", "credentials")
31+
with open(config_path, "a") as f:
32+
f.write("[credential]\n")
33+
f.write(f"helper = store --file {cred_path}\n")
34+
with open(cred_path, "w") as f:
35+
f.write("https://")
36+
f.write(environ["GIT_COMMITTER_NAME"])
37+
f.write(":")
38+
3F80 f.write(environ["GIT_COMMITTER_PASSWORD"])
39+
f.write("@github.com\n")
40+
c.run("poetry run ghp-import --cname dry-python.org --branch master --push site")

0 commit comments

Comments
 (0)
0