Update input defaults

This commit is contained in:
Peter Evans
2019-12-29 15:14:33 +09:00
parent bdadb3b4a0
commit b11cb71e96
4 changed files with 42 additions and 28 deletions

View File

@@ -15,6 +15,13 @@ DEFAULT_COMMITTER = "GitHub <noreply@github.com>"
DEFAULT_AUTHOR = (
"github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
)
DEFAULT_COMMIT_MESSAGE = "[create-pull-request] automated change"
DEFAULT_TITLE = "Changes by create-pull-request action"
DEFAULT_BODY = (
"Automated changes by "
+ "[create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action"
)
DEFAULT_BRANCH = "create-pull-request/patch"
def get_git_config_value(repo, name):
@@ -89,10 +96,8 @@ def set_committer_author(repo, committer, author):
github_token = os.environ["GITHUB_TOKEN"]
github_repository = os.environ["GITHUB_REPOSITORY"]
# Get environment variables with defaults
branch = os.getenv("CPR_BRANCH", "create-pull-request/patch")
commit_message = os.getenv(
"CPR_COMMIT_MESSAGE", "Changes by create-pull-request action"
)
branch = os.getenv("CPR_BRANCH", DEFAULT_BRANCH)
commit_message = os.getenv("CPR_COMMIT_MESSAGE", DEFAULT_COMMIT_MESSAGE)
# Get environment variables with a default of 'None'
committer = os.environ.get("CPR_COMMITTER")
author = os.environ.get("CPR_AUTHOR")
@@ -178,12 +183,8 @@ if result["action"] in ["created", "updated"]:
sys.exit()
# Fetch optional environment variables with default values
title = os.getenv("CPR_TITLE", "Auto-generated by create-pull-request action")
body = os.getenv(
"CPR_BODY",
"Auto-generated pull request by "
"[create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub Action",
)
title = os.getenv("CPR_TITLE", DEFAULT_TITLE)
body = os.getenv("CPR_BODY", DEFAULT_BODY)
# Create or update the pull request
coupr.create_or_update_pull_request(