-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
import re | ||
import subprocess | ||
import sys | ||
|
||
command_to_run = "flask db upgrade" | ||
environment = sys.argv[1] | ||
service = sys.argv[2] | ||
|
||
try: | ||
command = subprocess.run( | ||
args=[ | ||
"copilot", | ||
"task", | ||
"run", | ||
"--generate-cmd", | ||
f"pre-award/{environment}/{service}", | ||
], | ||
capture_output=True, | ||
check=True, | ||
text=True, | ||
) | ||
# Strip image argument as we want to build a new image to pick up new migrations | ||
command_with_image_removed = re.sub(r"--image \S+", "", command.stderr) | ||
except subprocess.CalledProcessError as e: | ||
print(e.stderr) | ||
raise e | ||
|
||
# Remove final line break and append arguments | ||
try: | ||
subprocess.run( | ||
args=command_with_image_removed[:-1] + f" \\\n--follow \\\n--command '{command_to_run}'", | ||
shell=True, | ||
check=True, | ||
) | ||
except subprocess.CalledProcessError as e: | ||
# Don't want to leak the command output here so just exit with the command's return code | ||
sys.exit(e.returncode) |