Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added warning if app already deployed #470

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/writer/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
WRITER_DEPLOY_URL = os.getenv("WRITER_DEPLOY_URL", "https://api.writer.com/v1/deployment/apps")

def deploy(path, token, env):
check_app(token)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add a quiet or force flag for continuous delivery

tar = pack_project(path)
upload_package(tar, token, env)

Expand Down Expand Up @@ -90,6 +91,27 @@ def match(file_path) -> bool: return False

return f


def check_app(token):
url = get_app_url(token)
if url:
print("[WARNING] This token was already used to deploy a different app")
print(f"[WARNING] URL: {url}")
print("[WARNING] If looking to deploy to a different URL, use a different API key. ")
if input("[WARNING] Are you sure you want to overwrite? (y/N)").lower() != "y":
sys.exit(1)

def get_app_url(token):
with requests.get(WRITER_DEPLOY_URL, params={"lineLimit": 1}, headers={"Authorization": f"Bearer {token}"}) as resp:
try:
resp.raise_for_status()
except Exception as e:
print(e)
print(resp.json())
return None
data = resp.json()
return data['status']['url']

def get_logs(token, params):
with requests.get(WRITER_DEPLOY_URL, params = params, headers={"Authorization": f"Bearer {token}"}) as resp:
try:
Expand Down
Loading