tooling(restep): push using PAT in ci
This commit is contained in:
parent
dce2d72b43
commit
acbfc24605
25
sync.py
25
sync.py
|
@ -45,7 +45,14 @@ COMMIT_AUTHOR: Final[str] = "sota staircase ReStepper <ssrestepper@joshwel.co>"
|
|||
NEUTERED_GITATTRIBUTES: Final[str] = (
|
||||
"""# auto detect text files and perform lf normalization\n* text=auto\n"""
|
||||
)
|
||||
IS_GH_ACT: Final[bool] = getenv("GITHUB_ACTIONS", "").lower() == "true"
|
||||
GH_ACT: Final[bool] = getenv("GITHUB_ACTIONS", "").lower() == "true"
|
||||
GH_TOKEN: Final[str] = getenv("SS_RESTEPPER_TOKEN", "")
|
||||
if GH_ACT and GH_TOKEN == "":
|
||||
print(
|
||||
"critical error: no personal access token found in SS_RESTEP_TOKEN, "
|
||||
"may not have permission to push to github"
|
||||
)
|
||||
exit(1)
|
||||
|
||||
# dictionary to share state across steps
|
||||
r: dict[str, str] = {}
|
||||
|
@ -410,7 +417,7 @@ def main() -> None:
|
|||
"directories\n"
|
||||
f" real repo : {REPO_DIR}\n"
|
||||
f" temp repo : {dir_temp}\n",
|
||||
f" is gh act : {IS_GH_ACT}\n" if IS_GH_ACT else "",
|
||||
f" is gh act : {GH_ACT}\n" if GH_ACT else "",
|
||||
sep="",
|
||||
)
|
||||
|
||||
|
@ -577,7 +584,7 @@ def main() -> None:
|
|||
)
|
||||
|
||||
def add_and_commit() -> CompletedProcess:
|
||||
if IS_GH_ACT:
|
||||
if GH_ACT:
|
||||
cp = cmd("git config user.name 'github-actions[bot]'")()
|
||||
if cp.returncode != 0:
|
||||
return cp
|
||||
|
@ -610,13 +617,15 @@ def main() -> None:
|
|||
err("critical error (whuh?): couldn't add github remote")
|
||||
r["remote/github"] = "github"
|
||||
|
||||
push_invocation = (
|
||||
f"git push {r['remote/github']} {branch} --force"
|
||||
if not GH_ACT
|
||||
else f"git push https://markjoshwel:{GH_TOKEN}@{REPO_URL_GITHUB}.git {branch} --force"
|
||||
)
|
||||
|
||||
step(
|
||||
desc=f"X fin | pushing to {r['remote/github']}/{branch}",
|
||||
func=cmd(
|
||||
f"git push {r['remote/github']} {branch} --force"
|
||||
if ("--test" not in argv)
|
||||
else "git --version"
|
||||
),
|
||||
func=cmd(push_invocation if ("--test" not in argv) else "git --version"),
|
||||
)
|
||||
|
||||
cumulative_end_time = time()
|
||||
|
|
Reference in a new issue