Plantilla inicial del taller
publicar / publicar (push) Failing after 8s

This commit is contained in:
taller committed 2026-11-22 18:51:26 +00:00
1 parent 182c87dc0a
commit 664c8e49a8
22 files changed
+1157

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
# Cada push a main: construye y publica las imágenes de api y web en el registro de Gitea
# y actualiza el tag en k8s/kustomization.yaml (commit del bot) para que Argo CD despliegue.
name: publicar
on:
push:
branches: [main]
paths-ignore: ["k8s/kustomization.yaml", "**.md"]
jobs:
publicar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Preparar variables
run: |
HOST="${GITHUB_SERVER_URL#*://}"
HOST="${HOST%/}"
echo "HOST=$HOST" >> "$GITHUB_ENV"
echo "REPO=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
echo "TAG=$(git rev-parse --short=8 HEAD)" >> "$GITHUB_ENV"
- name: Construir y publicar imágenes
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
set -euo pipefail
echo "$REGISTRY_TOKEN" | docker login "$HOST" -u ci-bot --password-stdin
docker build -t "$HOST/$REPO/api:$TAG" -f api/Dockerfile .
docker build -t "$HOST/$REPO/web:$TAG" web
docker push "$HOST/$REPO/api:$TAG"
docker push "$HOST/$REPO/web:$TAG"
- name: Desplegar (nuevo tag en k8s/kustomization.yaml)
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
set -euo pipefail
REMOTO="https://ci-bot:${REGISTRY_TOKEN}@${HOST}/${GITHUB_REPOSITORY}.git"
git config user.name "ci-bot"
git config user.email "ci-bot@taller.local"
for intento in 1 2 3 4 5; do
git fetch -q "$REMOTO" main && git checkout -q -B main FETCH_HEAD
sed -i -E "s/^( *newTag: ).*/\1\"$TAG\"/" k8s/kustomization.yaml
git commit -qam "despliegue $TAG [skip ci]" || { echo "Nada que desplegar"; exit 0; }
git push -q "$REMOTO" HEAD:main && { echo "Desplegando $TAG"; exit 0; }
echo "Otro push se adelantó; reintento ($intento)"; sleep 3
done
exit 1