REGISTRY:= gianet.us/codyops
IMAGE:= core
COUNTRIES:= ar br

.PHONY: init build setup $(addprefix step-,$(COUNTRIES))

init:
	direnv allow .

setup:
	npm install

build: setup $(addprefix step-,$(COUNTRIES))

$(addprefix step-,$(COUNTRIES)):
	@echo "Ejecutando step para el país: $(shell echo $(patsubst step-%,%,$@) | tr '[:lower:]' '[:upper:]')"
	export ASTRO_COUNTRY=$(shell echo $(patsubst step-%,%,$@) | tr '[:lower:]' '[:upper:]') && \
	export ASTRO_CURRENCY=${ASTRO_CURRENCY_$(shell echo $(patsubst step-%,%,$@) | tr '[:lower:]' '[:upper:]')} && \
	export ASTRO_SITE=${ASTRO_SITE_$(shell echo $(patsubst step-%,%,$@) | tr '[:lower:]' '[:upper:]')} && \
	export ASTRO_GTM=${ASTRO_GTM_$(shell echo $(patsubst step-%,%,$@) | tr '[:lower:]' '[:upper:]')} && \
	npx astro build --force
	podman build --pull=newer --tag $(REGISTRY)/$(IMAGE):$(patsubst step-%,%,$@) .
	podman push $(REGISTRY)/$(IMAGE):$(patsubst step-%,%,$@)
