mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Allow app names for datasette publish heroku
Lets you supply the `-n` parameter for Heroku deploys, which also lets you update existing Heroku deployments.
This commit is contained in:
parent
31a5d8fa77
commit
58fec99ab0
2 changed files with 25 additions and 6 deletions
|
|
@ -100,7 +100,7 @@ def inspect(files, inspect_file, sqlite_extensions):
|
|||
"-n",
|
||||
"--name",
|
||||
default="datasette",
|
||||
help="Application name to use when deploying to Now (ignored for Heroku)",
|
||||
help="Application name to use when deploying",
|
||||
)
|
||||
@click.option(
|
||||
"-m",
|
||||
|
|
@ -259,10 +259,29 @@ def publish(
|
|||
install,
|
||||
extra_metadata,
|
||||
):
|
||||
create_output = check_output(["heroku", "apps:create", "--json"]).decode(
|
||||
"utf8"
|
||||
)
|
||||
app_name = json.loads(create_output)["name"]
|
||||
|
||||
app_name = None
|
||||
if name:
|
||||
# Check to see if this app already exists
|
||||
list_output = check_output(["heroku", "apps:list", "--json"]).decode('utf8')
|
||||
apps = json.loads(list_output)
|
||||
|
||||
for app in apps:
|
||||
if app['name'] == name:
|
||||
app_name = name
|
||||
break
|
||||
|
||||
if not app_name:
|
||||
# Create a new app
|
||||
cmd = ["heroku", "apps:create"]
|
||||
if name:
|
||||
cmd.append(name)
|
||||
cmd.append("--json")
|
||||
create_output = check_output(cmd).decode(
|
||||
"utf8"
|
||||
)
|
||||
app_name = json.loads(create_output)["name"]
|
||||
|
||||
call(["heroku", "builds:create", "-a", app_name])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue