Skip to content
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
48 changes: 48 additions & 0 deletions gitops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,54 @@ def bump( # noqa: C901
print(success("Done!"))


@task
def redeploy(
ctx: Any,
filter: str,
exclude: str = "",
autoexclude_inactive: bool = True,
interactive: bool = True,
push: bool = False,
skip_migrations: bool = False,
) -> None:
"""Force redeploy selected app(s) without changing their image tag.
Updates a UUID bump field to trigger a new deployment.
Provide `push` to automatically push the commit (and retry on conflict.)
Provide `skip_migrations` to disable running migrations via helm hooks.
"""
try:
apps = get_apps(
filter=filter,
exclude=exclude,
autoexclude_inactive=autoexclude_inactive,
message=f"{colourise('The following apps will be redeployed:', Fore.LIGHTBLUE_EX)}",
load_secrets=False,
mode="PROMPT" if interactive else "SILENT",
)
except AppOperationAborted:
print(success_negative("Aborted."))
return

if push:
run(f"cd {get_apps_directory()}; git pull")

for app in apps:
print(f"Redeploying {colourise(app.name, Fore.LIGHTGREEN_EX)}")
update_app(app.name, **{"bump": str(uuid.uuid4())})

commit_message = f"Redeploying {filter}"
if exclude:
commit_message += f" (except {exclude})"
if skip_migrations:
commit_message += " --skip-migrations"
run(f'cd {get_apps_directory()}; git commit -am "{commit_message}."')

if push:
git_push(get_apps_directory())

print(success("Done!"))


@task
def command(
ctx: Any,
Expand Down
Loading