diff --git a/workloads/ecommerce/azure-pipelines.yml b/workloads/ecommerce/azure-pipelines.yml new file mode 100644 index 0000000..78af688 --- /dev/null +++ b/workloads/ecommerce/azure-pipelines.yml @@ -0,0 +1,39 @@ +trigger: + - main + +pool: + vmImage: 'ubuntu-latest' +https://gitea.cruzcloud.net/devops/apps-registry/src/branch/main/workloads/ecommerce +variables: + # Cambia esto por tu usuario de Gitea + registryName: 'gitea.cruzcloud.net' + imageName: 'devops/ecommerce-frontend' + tag: '$(Build.BuildId)' + +steps: +# 1. Construcción de Imagen Docker +- task: Docker@2 + displayName: 'Construir y Subir Imagen a Gitea' + inputs: + containerRegistry: 'gitea-registry-connection' # Nombre de la conexión que creamos en Azure DevOps + repository: '$(imageName)' + command: 'buildAndPush' + Dockerfile: '**/Dockerfile' + tags: | + $(tag) + latest + +# 2. Actualización GitOps (Notificar a Argo CD) +# Esto clona tu repo de despliegue, cambia la imagen y hace commit +- script: | + git clone https://$(gitea_token)@gitea.cruzcloud.net/devops/apps-registry.git + cd apps-registry/workloads/ecommerce + sed -i "s|image: .*|image: $(registryName)/$(imageName):$(tag)|g" frontend.yaml + git config user.email "cristiancruz0529@gmail.com" + git config user.name "Cristian" + git add frontend.yaml + git commit -m "Auto-update image tag to $(tag)" + git push origin main + displayName: 'Actualizar GitOps Repo' + env: + gitea_token: $(GITEA_TOKEN) # Token generado en Gitea configurado como variable secreta \ No newline at end of file