Skip to content

Commit 06141e0

Browse files
committed
setup git credentials in bump-n-release CI workflow
1 parent 0920526 commit 06141e0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

.github/workflows/bump_version.py

+12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import argparse
3737
from pathlib import Path
38+
from os import environ
3839
import subprocess
3940
import re
4041

@@ -135,6 +136,17 @@ def main():
135136
subprocess.run(["git", "add", "--all"], check=True)
136137
tag = "v" + Updater.new_version
137138
subprocess.run(["git", "commit", "-m", f"Bump version to {tag}"], check=True)
139+
if environ.get("CI", "false") == "true":
140+
# configure git credentials on CI runner
141+
# NOTE: this is design to fail locally with `KeyError`
142+
git_config = {"name": environ["GITHUB_ACTOR"]}
143+
git_config["email"] = (
144+
f'{environ["GITHUB_ACTOR_ID"]}+{git_config["name"]}@users.noreply.github.com'
145+
)
146+
for key, value in git_config.items():
147+
subprocess.run(
148+
["git", "config", "--global", f"user.{key}", value], check=True
149+
)
138150
try:
139151
subprocess.run(["git", "push"], check=True)
140152
except subprocess.CalledProcessError as exc:

0 commit comments

Comments
 (0)