39 lines
1.3 KiB
YAML
39 lines
1.3 KiB
YAML
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 "[email protected]"
|
|
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 |