Skip to content

Instantly share code, notes, and snippets.

@KyleJamesWalker
Created September 5, 2018 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyleJamesWalker/024c2d1b5067db8f1e4ee0b4a0b8c5d4 to your computer and use it in GitHub Desktop.
Save KyleJamesWalker/024c2d1b5067db8f1e4ee0b4a0b8c5d4 to your computer and use it in GitHub Desktop.
tasks - Invoke Fun
"""Example Build File"""
from invoke import task
from tasks.zefr_template import namespace
def build(ctx):
"""Build the image"""
print("Building Overridden!")
@task()
def deep_clean(ctx):
"""Additional cleaning"""
print("Custom Deep Clean~")
# Replace template build
namespace.tasks['build'].body = build
# Set deep_clean to happen before clean
namespace.tasks['clean'].pre.append(deep_clean)
# Expose deep_clean as a top level item
namespace.add_task(deep_clean)
"""Task Templates"""
from invoke import Collection, task
@task
def clean(ctx):
"""Clean the repo"""
print("Running docker-compose down")
@task(pre=[clean])
def build(ctx):
"""Build the image"""
print("Building!")
namespace = Collection(
build,
clean,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment