GeezerVison is showing github.com — Write Git credentials to the config file. (#351) · dry-python/dry-python.github.io@06cb30b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: tasks.py +14-5Lines changed: 14 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | from os import environ |
| 2 | +from os import getcwd |
| 3 | +from os.path import join |
2 | 4 |
|
3 | | -from invoke import Responder |
4 | 5 | from invoke import task |
5 | 6 |
|
6 | 7 |
|
@@ -25,7 +26,15 @@ def build(c): |
25 | 26 |
|
26 | 27 | @task |
27 | 28 | 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 | + 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") |