# Configures the default task to run
[tasks.default]
alias = "build-containers"

# Overrides the default build task
[tasks.build]
alias = "build-containers"

[tasks.build-sitemap-generator]
workspace = false
script = '''
PKG_VER=$(cargo pkgid --package=sitemap-generator | cut -d "#" -f2)
docker build --rm --target chef-sitemap-generator . -t ghcr.io/djkato/saleor-app-sitemap-generator:${PKG_VER}
'''

[tasks.build-simple-payment-gateway]
workspace = false
script = '''
PKG_VER=$(cargo pkgid --package=simple-payment-gateway | cut -d "#" -f2)
docker build --rm --target chef-simple-payment-gateway . -t ghcr.io/djkato/saleor-app-simple-payment-gateway:${PKG_VER}
'''

[tasks.build-containers]
workspace = false
dependencies = [
  "delete-images",
  "build-sitemap-generator",
  "build-simple-payment-gateway",
]

[tasks.push-containers]
workspace = false
script = '''
docker push ghcr.io/djkato/saleor-sitemap-generator:latest
docker push ghcr.io/djkato/saleor-simple-payment-gateway:latest
'''

[tasks.delete-images]
workspace = false
script = '''
docker rmi -f $(docker image ls -q --filter=label=service=chef-sitemap-generator) 2>&1 || true
docker rmi -f $(docker image ls -q --filter=label=service=chef-simple-payment-gateway) 2>&1 || true
'''
